mountPath会覆盖同一文件夹中的其余文件 [英] mountPath overrides the rest of the files in that same folder
问题描述
我有一个带有机密的卷,称为config-volume.我想将该文件放在其他配置文件所在的/home/code/config文件夹中.为此,我将其安装为:
volumeMounts:
- name: config-volumes
- mountPath: /home/code/config
问题在于,部署后,在/home/code/config中,我只有机密文件,其余文件都消失了
因此/home/code/config是一个现有文件夹(不为空),我怀疑volumeMount会覆盖该文件夹.
有没有一种方法可以在不覆盖所有内容的情况下完成此操作?
Kubernetes秘密作为目录安装,使用该目录中每个密钥作为文件.因此,在您的情况下,config-volumes
机密会挂载到/home/code/config
,从而掩盖该目录之前的所有内容.
您可以将卷安装指定为:
volumeMounts:
- name: config-volumes
- mountPath: /home/code/config/config-volumes
将在config
目录内提供一个config-volumes
目录,并在其中提供您的秘密密钥文件.
I have a volume with a secret called config-volume. I want to have that file in the /home/code/config folder, which is where the rest of the configuration files are. For that, I mount it as this:
volumeMounts:
- name: config-volumes
- mountPath: /home/code/config
The issue is that, after deploying, in the /home/code/config I only have the secret file and the rest of them are gone
So the /home/code/config is an existing folder (not empty), I suspect that the volumeMount overwrites the folder.
Is there a way that this can be done without overwriting everything?
Kubernetes Secrets are mounted as a directory, with each key as a file in that directory. So in your case, the config-volumes
secret is mounted to /home/code/config
, shadowing whatever that directory was before.
You could specify your volume mount as:
volumeMounts:
- name: config-volumes
- mountPath: /home/code/config/config-volumes
which would provide a config-volumes
directory inside the config
directory with files for your secret's keys inside.
这篇关于mountPath会覆盖同一文件夹中的其余文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!