比如我有个目录/dir ,里边已经有文件 a.txt,b.txt 。 想用 configMap 把 c.txt,d.txt ,也映射到/dir ,但是不覆盖掉 a.txt,b.txt 。
我尝试了把 c.txt,d.txt 放到一个 configMap 中,映射到/dir 时,发现只有 c.txt,d.txt ,其他文件都丢失了。 又尝试了分开放在两个 configMap 中,分别映射到/dir/c.txt,/dir/d.txt ,结果 c.txt ,d.txt 成了目录格式。
1
fengxsong 2023-07-27 11:24:32 +08:00
configured with `subPath`
|
2
wtfedc OP @fengxsong chatGPT 给了这个响应,但是前后矛盾。它后边的回答是这样:
``` Apologies for the confusion. You are right; using the subPath field in the volumeMounts will override the entire directory in the container with the contents of the ConfigMap, which is not the behavior we want. ``` |
3
wtfedc OP 最终用 subPath 搞定了,chatGPT3.5 给的答案不靠谱。
参考了这篇文章: https://dev.to/joshduffney/kubernetes-using-configmap-subpaths-to-mount-files-3a1i |