Hi I just started with exploring kubernetes. I tried to mount two files 1.yaml and 2.yaml via single configmap into the container. I see it is created as symlink and not able to view its contents.
configmap.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: sample-conf
data:
sample-config.yaml: |
{{ tpl ( .Files.Get "init/sample-config.yaml" ) . | indent 4 }}
sample1-config.yaml: |
{{ tpl ( .Files.Get "init/sample1-config.yaml" ) . | indent 4 }}
da-statefulset.yaml entry will look like:
apiVersion: v1
kind: Pod
metadata:
name: my-lamp-site
spec:
containers:
- name: container-a
image: My_image
volumeMounts:
- mountPath: /root/dir1
name: sample-profile
volumes:
- name: sample-profile
configMap:
items:
- key: sample-config.yaml
path: sample-config.yaml
- key: sample1-config.yaml
path: sample1-config.yaml
name: sample-conf
defaultMode: 0755
With the above code, ls /root/dir1 output as below:
lrwxrwxrwx. 1 root root 25 Feb 7 15:13 sample-config.yaml -> ..data/sample-config.yaml
lrwxrwxrwx. 1 root root 26 Feb 7 15:13 sample1-config.yaml -> ..data/sample1-config.yaml
-rw-r--r--. 1 root root 0 Feb 7 15:13 test1.txt
-rw-r--r--. 1 root root 0 Feb 7 15:13 test2.txt
[root@user dir1]# cat sample-config.yaml
cat: sample-config.yaml: No such file or directory
I understand that using "subPath" will solve this issue to mount file without symlinks. But if I use subPath, I could not able to get configmap updates. I don't want that to happen. I want to get configmap updates instead of redeploying the pod everytime when sample-config.yaml or sample1-config.yaml needs updation. It would be very helpful if anyone could direct me to proper solution in this case. Also I have few files under same directory i.e, /root/dir1 has test1.txt and test2.txt in addition to the yaml files. I don't want to lose them. Thanks in advance!