Let's see. We first create a config map called testcm
:
kubectl create configmap testcm --from-literal=somekey=INITIAL_VALUE
Now a pod that uses the testcm
config map in an environment variable and via a volume mount:
kubectl apply -f podusecm.yaml
Let's have a look at the value of the environment variable created from the config map:
$ kubectl exec -it cmtest -- env | grep SOME_KEY
SOME_KEY=INITIAL_VALUE
And now at the volume mount created from the config map:
$ kubectl exec -it cmtest -- cat /tmp/somekey
INITIAL_VALUE
Now we change the value of the config map data, that is, we assign the somekey
key in the testcm
config map a new value:
kubectl patch configmap testcm --type merge -p '{"data":{"somekey":"UPDATED_VALUE"}}'
And check again, first the environment variable:
$ kubectl exec -it cmtest -- env | grep SOME_KEY
SOME_KEY=INITIAL_VALUE
The value of the environment variable SOME_KEY
in the pod, which we created from the config map HAS NOT changed.
Finally, we check the volume mount:
$ kubectl exec -it cmtest -- cat /tmp/somekey
UPDATED_VALUE
The value of the file /tmp/somekey
in the pod, which we created from the config map HAS changed.
The config map data changes do propagate automatically if used via a volume mount, however not via environmment variables. See also Issue 22368 for details.