将一个文件共享/挂载到Pod中的最佳方法是什么? [英] What's the best way to share/mount one file into a pod?
本文介绍了将一个文件共享/挂载到Pod中的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我当时正在考虑使用机密文件来挂载单个文件,但是看来您只能挂载将覆盖所有其他内容的目录.如何在不挂载目录的情况下共享单个配置文件?
I was considering using secrets to mount a single file but it seems that you can only mount directory that will overwrites all the other content. How can I share a single config file without mounting a directory?
推荐答案
例如,您有一个configmap,其中包含2个配置文件:
For example you have a configmap which contain 2 config files:
kubectl create configmap config --from-file <file1> --from-file <file2>
您可以使用如下子路径将单个文件安装到现有目录中:
You could use subPath like this to mount single file into existing directory:
---
volumeMounts:
- name: "config"
mountPath: "/<existing folder>/<file1>"
subPath: "<file1>"
- name: "config"
mountPath: "/<existing folder>/<file2>"
subPath: "<file2>"
restartPolicy: Always
volumes:
- name: "config"
configMap:
name: "config"
---
完整示例此处
这篇关于将一个文件共享/挂载到Pod中的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文