If i change my ConfigMap key value after deployment, does deployment of that application which is using configMap values need to be restarted?

6/1/2018

i have a sample nodejs application which uses an envVar environment variable, i have deployed this on kubernetes cluster. I am passing the env variable through config map.

once deployed and when pods is all running, if i change my config map with new value. Should deployment of my nodejs application need to be redone after this?

configmap.yaml

kind: ConfigMap
apiVersion: v1
metadata:
  name: app1-config
  namespace: default
data:
  envVal: '12345' # initial value
  apiUrl: http://a4235a7ee247011e8aa6f0213eb6eb14-1392003683.us-west-2.elb.amazonaws.com/myapp4

after updating the configmap.yaml

configmap.yaml

kind: ConfigMap
apiVersion: v1
metadata:
  name: app1-config
  namespace: default
data:
  envVal: '56789' # changed value
  apiUrl: http://a4235a7ee247011e8aa6f0213eb6eb14-1392003683.us-west-2.elb.amazonaws.com/myapp4
-- Shruthi Bhaskar
kubernetes

1 Answer

6/1/2018

When you mount the keys from the ConfigMap as environment variables, you would need to restart your pod for the changes to take effect.

When you mount it as volume into you system, the files in the volume will be updated automatically. The update is not immediate, there is some TTL configured in the kubelet before it checks for changes / does the update. But it is normally quite quick. However it would still depend on your application how it loads the data from the file - whether it will be able to update its self on the fly when the files change or whether these data were loaded only once at startup.

-- Jakub
Source: StackOverflow