Suppose that I have a Deployment which loads the env variables from a ConfigMap:
spec.template.spec.containers[].envFrom.configMapRef
Now suppose that I change the data inside the ConfigMap.
When exactly are the Pod env variables updated? (i.e. when the app running in a pod sees the new env variables)
For example (note that we are inside a Deployment):
- If a container inside the pod crashes and it is restarted does it read the new env or the old env?
- If a pod is deleted (but not its RelicaSet) and it is recreated does it read the new env or the old env?
CodePudding user response:
After some testing (with v1.20) I see that env variables in Pod template are updated immediately (it's just a reference to external values).
However the container does not see the new env variables... You need at least to restart it (or otherwise delete and recreate the pod).
CodePudding user response:
When using a ConfigMap with env variables, the values are not updated. You have to restart the pod.
If you want hot reload, you can mount that ConfigMap as a volume. Then values are updated automatically, however the app has still to watch for that change.