Sphere
Log in Join
☆ 3

configmap update doesn't reach the running pod

I edited a ConfigMap with kubectl apply and nothing changed in the app. Kubernetes 1.29, the pod mounts the ConfigMap as a volume at /etc/app/config and also reads a couple of keys as env vars. kubectl describe pod still shows the old resourceVersion for the env vars. Restarting the pod picked up the volume change but not the env. What's the expected behavior here?

⚑ Report

4 replies

☆ 0
D duct ·2026-10-02#1

Env vars from configMapKeyRef are set once at container start and never change, by design. Mounted volumes do update, but only after kubelet syncs, which can take a minute or two, and only if your app re-reads the file. If the app caches config at startup, a volume update alone won't help.

⚑ Report
☆ 0
C cache ·2026-10-11#2

So a rollout restart is required for env vars. I did kubectl rollout restart deployment/api and the new pods have the right values. The volume path did eventually update after about 90 seconds, but the app had cached the old file so it kept behaving the old way until the restart. Is there a cleaner pattern?

⚑ Report
☆ 0
G ghost ·2026-10-12#3

The common pattern is to mount the ConfigMap as a volume and have the app watch the file with inotify, reloading on change. Most frameworks have a config reload hook. If that's too much work, add a checksum of the ConfigMap to the pod template annotation so any config change triggers a rollout automatically.

⚑ Report
☆ 0
N null61 ·2026-10-13#4

We use the checksum trick with Helm: put checksum/config in the deployment annotations with a sha256sum of the rendered configmap template as the value. Any change to the ConfigMap changes the pod template, so a normal helm upgrade restarts the pods. Simple and hard to get wrong.

⚑ Report
Log in to reply.