I have a pod (whose deployment config I have included below whichever I guessed as relevant to this question. Please tell me if more is needed) which uses a persistent volume. And the container is a docker whose docker file creates this folder /mounted/folder
and also some hierarchy of subfolders. After this pod is deployed, I can see that this /mounted/folder
is wiped clean of all the subfolders. I saw this question where it was mentioned that adding subPath
field will ensure that the folder contents are not deleted. But it didn't work. I may have to mention here that I have another pod using the same pvc which this pod is using (for having a common shared storage). When this subPath didn't work, I tried (unsuccessfully) to add subPath in that pod deployment also. Please help! Thanks!
spec:
containers:
- name: nginx
image: docker-registry-address/imagename:version
volumeMounts:
- mountPath: /mounted/folder
subPath: folder
name: name-of-volume
volumes:
- name: name-of-volume
persistentVolumeClaim:
claimName: pv-claim