1
votes

When changing a variable in a configmap, the environment variables inside running pods are not updated.

We have a stateful pod that cannot be restarted easily.

Trying to update the environment variable inside the container with

export VARIABLE_TO_BE_UPDATED="new value"

lasts a little while but is then rolled back automatically after some short time (maybe this has something to due with the open session).

Any way to update those environment variables (manually) in a persistent way without restarting the pod?

1
Maybe you can look sidecar pattern for dynamic configs. - Mücahit Inel

1 Answers

2
votes

You can't reload a ConfigMap that was already mounted. The ConfigMap is read from the API and dumped into a volume before the container is started, it remains static afterwards.

Another way to do this could be to use a sidecard container, watching over changes to those ConfigMaps, refreshing copies in some volume that would be shared with your application container, then instructing your application to reload its configuration. A common implementation for this would be the Prometheus Rule Reloader.