-
Notifications
You must be signed in to change notification settings - Fork 42.7k
Description
/kind bug
What happened:
I wanted to mount a ConfigMap and a Secret directly as a file and didn't want to mount it as a full directory, so I used subPath to do so:
volumeMounts:
- name: my-config
mountPath: /usr/src/app/config/config.json
subPath: config.json
- name: my-secret
mountPath: /usr/src/app/secret/secret.json
subPath: secret.json
volumes:
- name: my-config
configMap:
name: my-config
- name: my-secret
secret:
secretName: my-secretWhen the pod is created, it mounts the ConfigMap and Secret correctly. However, if I change them, the updates are not projected into the currently running pods. New pods get the updated file. According to the documentation, changes to a ConfigMap should be automatically propagated to running containers that mount them.
However, if I don't use subPath and instead mount the ConfigMap and Secret as a directory:
volumeMounts:
- name: my-config
mountPath: /usr/src/app/config
- name: my-secret
mountPath: /usr/src/app/secret
volumes:
- name: my-config
configMap:
name: my-config
- name: my-secret
secret:
secretName: my-secretThen the files are updated inside the container when the underlying ConfigMap and Secret are updated and everything works as expected.
Anything else we need to know?:
In both cases, the files are being updated on the host VM. @kelseyhightower and I tried to debug this, and the only conclusion we could come up with is that subPath is using a different method to mount the files (I think it is using symlinks), and these either aren't or can't be updated for whatever reason.
Action:
The behavior that files mounted with subPath don't get updated needs to be documented, or it needs to be fixed so that subPath mounts are updated when the underlying ConfigMap or Secret changes.
Environment: GKE
- Kubernetes version (use
kubectl version): 1.6.7 - Cloud provider or hardware configuration**: GKE n1-standard-1
- OS (e.g. from /etc/os-release): Container-Optimized OS 59 9460.64.0
- Kernel (e.g.
uname -a): 4.4.52+