Overview
At 1 AM I got a report about intermittent 429s. We had load-tested during the day and concluded that the rate limit on one path was set too low. So I changed a single number: rate_limit: 200 became rate_limit: 800. The kubectl apply succeeded, and kubectl get cm app-config -o yaml clearly showed 800.
Twenty minutes later, the 429s were still there.
I cat’ed the file inside the pod. It still said 200. My first thought was “wrong namespace” — no. Second thought: “another ConfigMap with the same name” — no. Third thought finally took me to the Deployment’s volumeMounts, where one line read subPath: config.yaml.
That one line was the whole problem. The Kubernetes documentation contains a note: “A container using a ConfigMap as a subPath volume mount will not receive ConfigMap updates.” I had read that sentence, but I read it as an edge case. In production it is silent: no error, no event, no failing probe, kubectl get pod shows everything Running, and a stale number sits quietly in effect inside the container.
After that night I re-worked “config delivery” as a standalone engineering problem. This article is the result. Core conclusions first:
- Config delivery breaks at three breakpoints, and they are at different layers: how it is mounted (volume vs environment variable vs subPath), whether the app re-reads it (Kubernetes swaps the file, never sends a signal), and propagation delay (the kubelet sync period). Any one of them produces the same symptom: you changed it, nothing happened.
- Hot reload is not free: far fewer settings can genuinely hot reload than most people assume, and the state inconsistency it introduces costs more than an extra rolling restart. My current production default is route config changes through the release pipeline, with hot reload reserved for rotating material like certificates and upstream tokens.
- Making pods restart must be driven by config content, not by human memory: the
checksum/configannotation is the cheapest and most GitOps-friendly mechanism. Reloader works, but two of its default settings fail silently.
Below, in breakpoint order.
First, Count How Many Paths “Config Delivery” Actually Has
Many people think of a ConfigMap as “a config file that lives in the cluster”. That mental model causes every misunderstanding that follows. A ConfigMap is an API object, and there are three completely different channels between it and your process.
| Consumption method | When it reaches the container | What happens when config changes | Typical misuse |
|---|---|---|---|
env / envFrom | Written into the process environment by the kubelet at container start | Never updates; pod rebuild required | Assuming the ConfigMap edit takes effect |
| Whole-directory volume mount | Directory mounted at start, then periodically synced | Files are eventually replaced (~60-90s) | Assuming a new file means a new value |
Volume mount + subPath | Single file’s inode bind-mounted at start | Never updates | Most common, most hidden |
| App reads the API directly (informer/watch) | Real time | Real time | Over-broad RBAC, configuration drift hard to audit |
The difference between these channels is not an implementation detail; it is a design decision. Environment variables are copied by the kernel into the process address space at execve() (/proc/<pid>/environ). That memory belongs to the process, and there is no legitimate external way to modify it. So “changing an environment variable” is technically impossible — only “restart the process with a different environment”.
Volume mounts look like they update, but the update mechanism is not a file write either. The kubelet uses an atomic writer: create a new timestamped directory, write the new content, atomically repoint the ..data symlink to the new directory, then rename() over it. The user-visible file path is always a symlink into ..data/xxx.
That design solves a real problem — an application never reads a half-written config file. It also creates two new problems, which are exactly breakpoint one and breakpoint two.
Breakpoint One: subPath Freezes the inode at Start
subPath has a legitimate use case: a ConfigMap holds five keys, you want only nginx.conf inside an existing /etc/nginx/ directory, and you do not want the volume to take over the whole directory. So you write:
# Looks perfectly reasonable. It was the root cause of that incident.
spec:
containers:
- name: app
volumeMounts:
- name: app-config
mountPath: /etc/app/config.yaml
subPath: config.yaml # this line kills hot reload entirely
volumes:
- name: app-config
configMap:
name: app-config
subPath works by resolving the symlink chain into a real inode at container start and bind-mounting that inode. The defining property of a bind mount is that it remembers the inode number from mount time. After that, no matter which new directory ..data points to, the container still sees the old inode.
You can verify the mechanism directly on two pods, one with a directory mount and one with subPath:
# First update a key of the same ConfigMap to v2
kubectl create configmap demo-cm --from-literal=key=v1 --dry-run=client -o yaml | kubectl apply -f -
# After one kubelet sync cycle (about 60-90 seconds), compare inodes
for p in demo-dir demo-sub; do
echo "--- $p ---"
kubectl exec "$p" -- stat -c 'inode=%i' /etc/demo/key
kubectl exec "$p" -- cat /etc/demo/key
done
The observed output looked like this:
--- demo-dir ---
inode=2097200 # new inode, value is already v2
v2
--- demo-sub ---
inode=2097154 # still the inode from container start
v1
Same filename, same path, two different inodes underneath. ls -l, md5sum, diff all show nothing unusual. Only stat reveals it.
Upstream has argued about this for eight years. Issue #50345 was filed in 2017, was discussed, reproduced, and root-caused (symlink plus bind mount) — then stalled at “documented, no fix planned”. Later issues #92296 and #68211 are variants of the same problem. In other words: do not treat subPath hot reload as a bug waiting to be fixed. It is the stable behavior of the current design.
There are only three fixes, with different costs:
| Approach | How | Cost | When I use it |
|---|---|---|---|
| Whole-directory mount | Drop subPath, point mountPath at a dedicated directory | Requires changing the app’s config path, or covering it with a symlink | My default, a path conflict is the smallest price |
Precise projection with items | Select keys with items and rename them, still under a directory | Renames only; does not solve “directory already occupied” | Directory can be dedicated but only some keys are needed |
| initContainer copy | Init container copies files into an emptyDir mounted by the main container | Copy happens at start — same semantics as subPath, but at least explicit | Must keep the original path and do not want an operator |
The third option has a trap worth stating plainly: copying into an emptyDir in an initContainer is still a start-time snapshot. It is no more hot-reloadable than subPath. Its only value is writing “not hot-reloadable” into the manifest where the next person will see it. If someone on the team reflexively reaches for subPath to save effort, the initContainer will at least trigger a review question: “why doesn’t this need to hot reload?”
Breakpoint Two: The File Changed, the App Never Reads It
Suppose you clear breakpoint one and switch to a directory mount, and the file really does update. You then find the app still using the old configuration.
This is not Kubernetes’ fault. Your application was never trained to re-read config. The file is data; reloading is an action. Kubernetes only handles the former.
Here is a detail I have hit that most articles never mention: because of the atomic writer, standard inotify watchers never see IN_MODIFY.
The file is not modified in place; the ..data symlink is atomically replaced by rename(). To an inotify watcher watching a specific file, the old inode disappears — the event it receives is IN_DELETE_SELF (sometimes accompanied by IN_CREATE on the ..data directory), not IN_MODIFY or IN_CLOSE_WRITE.
Here is a Go hot-reload watchdog; the wrong and right versions differ in a few lines:
// Wrong: watches the file path itself and only handles Write events
watcher, _ := fsnotify.NewWatcher()
watcher.Add("/etc/app/config.yaml") // watches the old inode
for {
select {
case ev := <-watcher.Events:
if ev.Op&fsnotify.Write == fsnotify.Write {
reload() // the atomic swap never emits Write, so this never fires
}
}
}
// Right: watch the directory, handle Create/Remove/Rename, and re-Add
watcher, _ := fsnotify.NewWatcher()
watcher.Add("/etc/app") // watch the directory, not the file
for {
select {
case ev := <-watcher.Events:
// the atomic writer emits Rename / Create (for the ..data switch)
if ev.Op&(fsnotify.Create|fsnotify.Rename) != 0 &&
strings.HasSuffix(ev.Name, "..data") {
debounceReload() // debounce; one switch can emit several events
}
case err := <-watcher.Errors:
log.Printf("watch error, rebuild watcher: %v", err)
watcher, _ = fsnotify.NewWatcher() // the watcher may be dead; rebuild it
watcher.Add("/etc/app")
}
}
Three points: watch the directory rather than the file, handle Rename/Create rather than Write, and always debounce. A single ConfigMap update can fire several events in a row; without debounce you reload five times in one second, some of them reading intermediate state.
reload() itself also needs care. nginx needs an explicit nginx -s reload after reading config — Kubernetes will not send that signal for you. A Java app changing log level needs Spring’s @RefreshScope or an Actuator endpoint. A Go service using viper.WatchConfig() handles Rename events inconsistently across versions, so verify after every upgrade.
I put the capability differences into a table. Check it before choosing “mount a config file”:
| Component | Native reload support | Trigger | Notes |
|---|---|---|---|
| nginx | Yes | nginx -s reload (or SIGHUP) | Needs external trigger; workers switch gracefully |
| Envoy | Partial | xDS, or restart with --drain-time-s | Static config does not hot reload; production mostly uses xDS |
| Prometheus | Yes | SIGHUP or /-/reload | Requires --web.enable-lifecycle at startup |
| Java (Spring Boot) | Partial | @RefreshScope + Actuator | Covers only Spring-managed beans; static fields unaffected |
| Redis | Yes | CONFIG SET or CONFIG REWRITE | File edits do not take effect automatically |
| In-house Go services | No | You write the watch yourself | Most teams leave this cell empty |
That last row reflects the real distribution I have seen: most in-house services answer “No”, yet they all mount ConfigMaps. That is the most common shape of breakpoint two — not a technical problem, but nobody ever acceptance-tested hot reload on a service that never promised it.
Breakpoint Three: Propagation Delay, and Why Not to Shrink It
Even after the first two breakpoints are cleared, a gap remains between a successful kubectl apply and the file actually changing.
It consists of two parts: the kubelet’s syncFrequency (default 1 minute) plus ConfigMap/Secret cache propagation delay (governed by configMapAndSecretChangeDetectionStrategy, default Watch).
I once recorded the timeline at 10-second intervals on a test cluster (single node, small ConfigMap, watch mode):
| Timestamp | Event | Observation |
|---|---|---|
| T+0s | kubectl apply returns configured | Object is in etcd; kubectl get shows the new value immediately |
| T+0s–T+3s | Watch event reaches the kubelet | Depends on the kubelet’s connection to the API server |
| T+12s | ..data atomically replaced in the volume | stat shows a new inode |
| T+12s | The app’s reload watchdog fires | Only if breakpoint two is already fixed |
| T+58s | Probes and business metrics reflect the new threshold | Depends on how quickly the app uses the value |
So “change it and verify immediately” is not a reliable habit. When someone in the ops channel says “done, take a look”, and the other person inspects the file within five seconds, they will most likely see the old value and start doubting everything. That is how the first 20 minutes of my incident were wasted.
Tools with --output-watch-events show API-side changes instantly, but that does not mean the node side has changed. The only reliable anchor for “config has landed” is the value actually read inside the container, and you must wait one sync cycle.
Some people want to lower syncFrequency to 10 seconds for “faster hot reload”. I do not recommend it, for a plain reason: every kubelet sync walks all pods on that node that mount ConfigMaps or Secrets. In a 200-node cluster with hundreds of pods per node, a 6x higher sync rate drives API server QPS and kubelet CPU up together. The payoff is “wait 50 seconds less” — far worse than putting config changes into the release pipeline, which already has a 2-5 minute canary window. Fifty seconds is not worth optimizing.
If you genuinely need second-level config push (risk rules, feature flags), do not use ConfigMap for it. Give the app a direct connection to a config service, or add an informer. Using the wrong mechanism to solve a latency problem ends in a system that is harder to maintain.
A Reproducible End-to-End Experiment
The conclusions above blur together if you only read about them. I keep a fixed comparison experiment in the test cluster: four Deployments for four consumption methods, runnable in 10 minutes, more reliable than reading docs.
Start with the namespace and the config object. Note the initial value is deliberately rate_limit: 200; we will change it to 800.
apiVersion: v1
kind: Namespace
metadata:
name: config-lab
---
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: config-lab
data:
config.yaml: |
rate_limit: 200
log_level: info
All four consumption methods in one file so they can be applied at once. The image is busybox, looping and printing the file content so you do not need to exec into the container:
# 1) Directory mount: the kubelet atomically swaps ..data, content changes
apiVersion: apps/v1
kind: Deployment
metadata:
name: mode-dir
namespace: config-lab
spec:
replicas: 1
selector:
matchLabels: { app: mode-dir }
template:
metadata:
labels: { app: mode-dir }
spec:
containers:
- name: app
image: busybox:1.36
command: ["sh", "-c", "while true; do date -u +%H:%M:%S; cat /etc/app/config.yaml; sleep 5; done"]
volumeMounts:
- name: cfg
mountPath: /etc/app # whole directory, no subPath
readOnly: true
volumes:
- name: cfg
configMap:
name: app-config
---
# 2) subPath mount: the inode is fixed at start, content stays v1 forever
apiVersion: apps/v1
kind: Deployment
metadata:
name: mode-subpath
namespace: config-lab
spec:
replicas: 1
selector:
matchLabels: { app: mode-subpath }
template:
metadata:
labels: { app: mode-subpath }
spec:
containers:
- name: app
image: busybox:1.36
command: ["sh", "-c", "while true; do date -u +%H:%M:%S; cat /etc/app/config.yaml; sleep 5; done"]
volumeMounts:
- name: cfg
mountPath: /etc/app/config.yaml
subPath: config.yaml # the incident was this line
readOnly: true
volumes:
- name: cfg
configMap:
name: app-config
---
# 3) Environment injection: the environment is copied by the kernel at execve, never changes
apiVersion: apps/v1
kind: Deployment
metadata:
name: mode-env
namespace: config-lab
spec:
replicas: 1
selector:
matchLabels: { app: mode-env }
template:
metadata:
labels: { app: mode-env }
spec:
containers:
- name: app
image: busybox:1.36
command: ["sh", "-c", "while true; do date -u +%H:%M:%S; echo \"env=$RATE_LIMIT\"; sleep 5; done"]
env:
- name: RATE_LIMIT # single value, fixed at start
valueFrom:
configMapKeyRef:
name: app-config
key: rate_limit
The third Deployment actually fails to create, because app-config has no key named rate_limit (it is inside the config.yaml content, not a key). That failure is a good teaching moment: ConfigMap keys and fields inside a file are two separate layers, and configMapKeyRef can only reference keys, never file content. This is the first trap most people hit when doing env injection.
To make the third work, split the ConfigMap into two pieces of data — one as a file, one as a key:
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: config-lab
data:
config.yaml: |
rate_limit: 200
log_level: info
rate_limit: "200" # a separate key, for env
Then verify. The key is to record a baseline before changing config, then sample at intervals afterwards:
# Baseline: before the change, record the inode and value each pod sees
kubectl -n config-lab get pod -l app=mode-dir -o name | head -1 | xargs -I{} kubectl -n config-lab exec {} -- stat -c '%i' /etc/app/config.yaml
kubectl -n config-lab get pod -l app=mode-subpath -o name | head -1 | xargs -I{} kubectl -n config-lab exec {} -- stat -c '%i' /etc/app/config.yaml
# Change: 200 -> 800
kubectl -n config-lab patch configmap app-config --type merge \
-p '{"data":{"rate_limit":"800","config.yaml":"rate_limit: 800\nlog_level: debug\n"}}'
# Sample at T+15s / T+60s / T+120s; watch whether inode changes and value changes
sleep 15
for i in 1 2 3; do
for d in mode-dir mode-subpath mode-env; do
pod=$(kubectl -n config-lab get pod -l app=$d -o jsonpath='{.items[0].metadata.name}')
if [ "$d" = "mode-dir" ] || [ "$d" = "mode-subpath" ]; then
echo "$d $i: $(kubectl -n config-lab exec $pod -- stat -c '%i' /etc/app/config.yaml) $(kubectl -n config-lab exec $pod -- cat /etc/app/config.yaml | tr '\n' ' ')"
else
echo "$d $i: $(kubectl -n config-lab exec $pod -- printenv RATE_LIMIT)"
fi
done
sleep 50
done
On a 1.28 cluster I got this shape, fully consistent with the documentation:
| Observation | Directory mount | subPath mount | env injection |
|---|---|---|---|
Value in kubectl get cm | 800 immediately | 800 immediately | 800 immediately |
| inode inside the container | New by T+15s | Always the start-time one | No file |
| File content inside the container | 800 by T+15s–T+40s | 200 forever | No file |
| Value inside the process | N/A | N/A | 200 forever |
| Action required | App re-reads actively | Delete and recreate the pod | Rolling restart |
| Signal required | File event | None | None |
The most valuable row is “inode inside the container”. It turns “changed but not applied” from folklore into a mechanical check that one stat settles. I sent those two commands to the team after the postmortem; time to localize this class of issue dropped from about 40 minutes to under 5.
You can also confirm one more detail: the timestamp in the ..data directory name. It changes on every sync, making it the most direct evidence of whether the kubelet has synced at all:
# Compare once before and after sync; a changed timestamp means the node has the new data
kubectl -n config-lab exec <pod> -- ls -l /etc/app/
# lrwxrwxrwx ... ..data -> ..2026_11_24_00_12_31.123456789
# lrwxrwxrwx ... config.yaml -> ..data/config.yaml
Note that the config.yaml line is a symlink, not a file. That is why “cat shows the old content” and “checksum verification fails” appear together — you are hashing the old inode the symlink resolves to. Do not hash the symlink itself when validating config; it solves nothing.
Who Restarts the Pod
Once the breakpoints are separated, the engineering question becomes a choice: Kubernetes will not restart on config change, so who does it, and how do we guarantee nothing is missed?
Three approaches I have used in production, ordered by reliability.
Option A: Manual kubectl rollout restart
kubectl apply -f configmap.yaml
kubectl rollout restart deployment/app-api
kubectl rollout status deployment/app-api --timeout=300s
Zero cost, works immediately. The downside is that it depends on people remembering. With three people and a few changes a week, that is fine. With eight people and 40 config changes a week, something will be missed. I measured the miss rate over a period: roughly 1 in 10, and the missed ones tended to be the kind that do not fail loudly — the worst category.
Option B: checksum/config annotation, driving template changes from config content
Put a hash of the config content into the pod template annotations. Config changes, annotation changes, template changes, the Deployment rolls itself. Nobody needs to remember anything.
In Helm:
# templates/deployment.yaml
spec:
template:
metadata:
annotations:
# sha256 over the rendered ConfigMap; content change -> annotation change -> ReplicaSet roll
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
spec:
containers:
- name: app
envFrom:
- configMapRef:
name: {{ include "app.fullname" . }}-config
Kustomize has no template functions, so the standard approach is name hashing:
# kustomization.yaml
configMapGenerator:
- name: app-config
files:
- config.yaml
# the generated name becomes app-config-7f8d2b4k9t; name change -> reference change -> guaranteed roll
There is exactly one criterion: the hash must land inside the pod template, not only in the Deployment’s top-level metadata. On the top level, the object changes but the template does not, the ReplicaSet never moves, and you have accomplished nothing. I have seen this mistake in review more than once, because after apply, kubectl get deploy does show a different annotation — it looks like it worked.
Option B is my current default, for three reasons: no extra component, GitOps-friendly (the change is declarative and diffable), and atomic rollback (rolling back a Helm release rolls config and template together).
It has a cost: changing one environment variable triggers a full rollout. For a service with 30 replicas and a 90-second startup, that is a real cost per config change. So pair it with sensible maxUnavailable/maxSurge and a PodDisruptionBudget — do not let a config change drain your capacity.
Option C: The Reloader controller
Stakater’s Reloader is an operator: it watches ConfigMap/Secret changes and patches the workloads that reference them to trigger a rollout. One annotation on the workload:
metadata:
annotations:
reloader.stakater.com/auto: "true"
It saves you from writing hashes into templates, which suits teams with many existing services that cannot easily change Helm templates. But two of its defaults fail silently, and I have hit both in production:
Trap one: watchGlobally defaults to false. A default Helm install only acts within Reloader’s own namespace. Deployments in other namespaces are silently ignored even with the annotation — no error, no alert, nothing obvious in the logs. You just find that “it is configured but does not work”. Turn it on explicitly:
helm install reloader stakater/reloader \
--namespace reloader --create-namespace \
--set reloader.watchGlobally=true
Trap two: updating a Deployment and its ConfigMap in the same batch rolls twice. With helm upgrade changing both the image and the config, the Deployment changes on its own (rollout #1), then Reloader detects the ConfigMap change and patches an annotation (rollout #2). Pods from rollout #1 already mount the new config, so rollout #2 is entirely redundant. This is described in full in Reloader issue #992; the pause-period annotation only delays it, it cannot coalesce.
An extra rollout is not merely wasteful. For a service with a PDB and tight replica count, two overlapping rollouts push available replicas to the floor; if the new config itself is bad, your rollback window shrinks too.
My rule: never use Option B and Option C on the same workload. Both trigger rollouts, and stacking them reproduces trap two. Pick one and write it into the standard.
| Dimension | A: manual restart | B: checksum annotation | C: Reloader |
|---|---|---|---|
| Depends on | Human discipline | Template tooling | An extra controller in the cluster |
| GitOps friendliness | Poor (the action is not in Git) | Good (declarative) | Medium (controller mutates workloads; Argo may report drift) |
| Miss risk | High | None | None (given watchGlobally) |
| Extra rollout risk | None | None | Yes (double roll on same-batch updates) |
| Best for | Emergencies, temporary environments | Default choice | Many legacy services, templates hard to change |
Five Extra Constraints That Come With Secrets
Many teams treat a Secret as “an encrypted ConfigMap” and assume the delivery conclusions transfer. The mount behavior is indeed the same (subPath does not update, inodes stay fixed), but a Secret carries five constraints a ConfigMap does not — and three of them produce security incidents rather than outages.
One: base64 is not encryption. Values in data are merely encoded; etcd stores plaintext. Anyone with an etcd snapshot or get secrets permission reads them directly. Encryption only exists once EncryptionConfiguration is enabled, and after rotating the KMS key you must rewrite historical objects — adding the config does not re-encrypt old data automatically.
# apiserver EncryptionConfiguration snippet: use KMS v2 rather than local aescbc
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
- secrets
providers:
- kms:
apiVersion: v2
name: prod-kms
endpoint: unix:///var/run/kmsplugin/socket.sock
- identity: {} # fallback: allows reading not-yet-encrypted historical data
That identity fallback cannot be dropped. Without it, historical plaintext Secrets become unreadable the moment the encryption config lands, and services across the cluster fail to start. I nearly hit this ordering problem during a hardening project: let new writes go through KMS first, then rewrite historical objects in batches, and only then consider removing identity.
Two: Secrets mounted as volumes land in tmpfs on Linux nodes. Never written to disk — good. Windows nodes have no tmpfs, so Secrets go to local disk and security depends on file ACLs and volume encryption. If the cluster has Windows nodes, put this in the audit scope.
Three: file permissions must be explicit. The default is 0644, readable by any process. Secret volumes should use 0400:
volumes:
- name: tls
secret:
secretName: app-tls
defaultMode: 0400 # owner read only
Four: injecting Secrets as env vars is an anti-pattern. Environment variables are inherited by child processes, end up in core dumps, appear in plaintext in the container spec inside kubectl describe pod, and get scraped by APM process-info collectors. I once gcore’d a process while debugging memory and found a database password inside the dump. Secrets go through volumes, no exceptions.
Five: rotation does not notify the application. The kubelet writes the new certificate into the volume; the app’s certificate chain cache may not invalidate. A Go service using a GetCertificate callback must detect file changes and reload; one using one-shot LoadX509KeyPair must restart. This belongs to the “rotating config” class: hot reload is allowed, but it must be proven.
| Constraint | ConfigMap | Secret | Handling |
|---|---|---|---|
| Storage encryption | N/A | Plaintext in etcd by default | Enable KMS v2, rewrite historical objects |
| Node disk | Written to disk | tmpfs on Linux, disk on Windows | Assess separately if Windows nodes exist |
| File permissions | 0644 by default | 0644 by default | Set defaultMode: 0400 explicitly |
| env injection risk | Medium | High (child processes, dumps) | Volume mounts only |
| Rotation notification | N/A (config does not rotate) | None | App-side proof or rolling restart |
| subPath behavior | Never updates | Never updates (identical) | Same as ConfigMap |
Changing Tools Does Not Change Behavior: GitOps Differences
Option B’s principle is putting a config hash in the pod template, but the three mainstream tools do it differently, with different traps.
Helm uses template functions, most directly — shown earlier. One warning: $.Template.BasePath must match the real file location. If the path is wrong, include returns an empty string, sha256sum of an empty string is a constant — so the annotation never changes, never rolls, and nothing errors. My first attempt had the wrong path, and I only noticed because “changed the config and it did not roll”.
Kustomize has no template functions; it relies on configMapGenerator producing a name with a hash suffix. The name changes, so the Deployment reference must change too — that is what nameReference handles:
# kustomization.yaml
configMapGenerator:
- name: app-config
files:
- config/config.yaml
options:
immutable: true # the generator supports immutable directly
- name: app-secret
literals:
- token=changeme
generatorOptions:
disableNameSuffixHash: false # false is the default; keep it
disableNameSuffixHash: true is a dangerous switch. With the suffix off, a ConfigMap whose content changes keeps its name, references stay the same, and the Deployment perceives nothing — Option B is silently disabled. I saw someone flip it globally during a “reduce resource name noise” cleanup; afterwards no config change in that environment triggered a rollout, until someone complained that “changing config requires a manual restart”.
ArgoCD has the opposite problem: if you also run Reloader, the controller writes to spec.template.metadata.annotations, ArgoCD classifies that as OutOfSync (drift), syncs the Git version back, and the patch disappears — the rollout may not happen, or may happen twice. Two options: use Argo Rollouts’ restart strategy (deletes pods without changing the template), or explicitly ignore that difference:
# Declare the controller-written annotation as ignored so Argo does not revert Reloader's patch
spec:
ignoreDifferences:
- group: apps
kind: Deployment
jsonPointers:
- /spec/template/metadata/annotations/reloader.stakater.com~1last-reloaded-from
| Tool | Trigger mechanism | Main risk | Rollback atomicity |
|---|---|---|---|
| Helm | checksum/config template function | Wrong path -> constant hash -> never rolls | Good, release-level rollback |
| Kustomize | Name hash suffix + nameReference | Disabling disableNameSuffixHash breaks it | Good, a Git revert suffices |
| ArgoCD | Git sync plus optional controller | Controller patch seen as drift and reverted | Good, needs ignoreDifferences |
| Flux | Kustomize controller, as above | As above | Good |
The conclusion stands: whatever tool you use, the criterion is “did the pod template change”. Check the ReplicaSet creation time — the command was given earlier and beats inspecting annotations.
Why I Eventually Dropped Hot Reload
Everything above is about “how to make hot reload work”. Once it worked, I removed it. Not because it is technically impossible, but because the economics do not add up.
Hot reload’s implicit assumption is “only this one variable changed”. At runtime, far more than that one value is affected by configuration:
- Change the connection pool size and existing connections do not shrink immediately; they wait for idle reclamation. During that window, actual concurrency does not match configuration.
- Change a rate limit and the token bucket still holds tokens accumulated at the old rate. The effective curve is gradual.
- Change the log level and already-emitted logs are not re-emitted. During troubleshooting you will see a sudden density change and misread it.
- Rotate a TLS certificate and the in-memory chain cache in some client libraries does not invalidate; a restart is required for a clean state.
None of these are bugs; they are inevitable consequences of partial application. A rolling restart is blunt, but its semantics are clean: new config means new process, with no half-new state. For someone woken up at 3 AM, “clean” beats “smooth”.
Auditability matters more. Config changes now travel the same path as code changes: Git commit, CI validation, canary, observe metrics, full rollout. That path has change records, approvals, and rollback. Hot reload is a side door: kubectl edit cm, effective five minutes later, no commit, no diff. When something breaks, reconstructing “what did we change” depends on chat history.
So the current standard splits config in two:
Two classes of config, two paths.
| Config class | Examples | Delivery | Activation |
|---|---|---|---|
| Structural | DB endpoint, pool size, rate limits, thread counts, log level | ConfigMap/Secret via volume or env | Release pipeline rollout, no hot reload |
| Rotating | TLS certs, upstream tokens, feature flags, dynamic blocklists | Secret via volume mount | Hot reload allowed, must be proven (below) |
“Proven” is my only condition for allowing hot reload: the setting must have an automated test showing it takes effect without a restart. The test is crude but cheap — mount a real volume, change the ConfigMap, wait 90 seconds, assert the effective in-process value changed. It costs little and blocks 90% of “assumed to be hot-reloadable”.
One useful mechanism: mark structural config immutable: true.
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config-v7 # version in the name
immutable: true # once set it is irreversible: content cannot change, only delete and recreate
data:
config.yaml: |
rate_limit: 800
immutable has concrete benefits: the kubelet stops watching the object (saving watch connections and memory in the API server); it prevents anyone from bypassing the pipeline with kubectl edit; and with a versioned name, the reference in the Deployment is an explicit version binding, so rollback means changing the reference.
The cost is that it is irreversible — you cannot revert to mutable or change data. Hence the versioned name, and evolution by creating v8 and updating the reference. That also makes it a natural fit for Option B: the version is in the name, so a rollout is guaranteed.
Capacity and Overhead: The Numbers Nobody Measures
Beyond “right or wrong”, config delivery has a “cheap or expensive” dimension. Few articles cover it, so I will, because it has caused real production incidents.
The 1 MiB limit is inherited from etcd.
| Layer | Limit | Value | Notes |
|---|---|---|---|
| etcd | Single request size | 1.5 MiB | Writes beyond this are rejected |
| Kubernetes API | Serialized object size | 1 MiB | Leaves 0.5 MiB for etcd protocol overhead and metadata |
| Volumes per node | Number of mounted ConfigMaps | No hard limit, bounded by node resources | Each mount consumes inodes and memory |
| Recommendation | Per ConfigMap | <= 200 KiB | Rule of thumb, see below |
The error for exceeding 1 MiB looks like this, and does not tell you where the limit comes from:
Error from server (Invalid): error when creating "big-config.yaml":
ConfigMap "app-config" is invalid: data: Too long: must have at most 1048576 bytes
Why not run close to 1 MiB. On one cluster we sampled: the larger the ConfigMap, the longer a pod takes from start to Ready, and the higher the kubelet memory footprint. The reason is straightforward — the kubelet caches the whole object in memory, writes it out at mount time, and does so for every pod that references it. Going from 20 KiB to 900 KiB moved median start-to-Ready for the same batch of pods from 6 seconds to 19 seconds. Add image pulls and probes, and during batch scale-outs this turns into tens of seconds of scheduling delay.
This cost becomes an incident in two scenarios: HPA scaling on a traffic peak, where pods start slower and scaling cannot keep up; and node reboot, where all pods mount large configs simultaneously, the kubelet’s CPU saturates, and NodeNotReady fires. I have seen the second: a 2 MiB certificate bundle split into two ConfigMaps blocked sync for four minutes during a node reboot.
What immutable: true actually saves. Semantically it means “do not change”; operationally it removes the object from the kubelet’s watch set. For 200 nodes, 80 pods per node, 20 referenced ConfigMaps, a mutable ConfigMap means every change broadcasts to every node’s watch stream; once immutable, those objects leave the watch scope. apiserver_watch_events_total reflects it directly.
| Measure | What it saves | Cost |
|---|---|---|
immutable: true | kubelet watch overhead, API server broadcast | Irreversible; delete and recreate only |
| Split into smaller ConfigMaps | Per-object size, startup blocking | More mount points, more to manage |
| Keep under 200 KiB | Overall startup latency | Requires discipline in config authoring |
Raising syncFrequency | Nothing (this is a reverse optimization) | Higher API server QPS |
The last row is deliberate, because it is the first thing many people reach for. Its payoff is “wait 50 seconds less”; its cost is cluster-wide API load. The math never works out.
A Config Delivery Standard You Can Actually Enforce
Compressing all of the above into something that can go into a team standard, here are eight rules:
- Structural config goes through the release pipeline. Config changes must go through Git;
kubectl editis forbidden. Restrictedit/patch configmapsin production namespaces via RBAC, granting it only to the CI service account. - No
subPathfor files that must hot reload. If it is unavoidable, state the reason in the manifest and confirm during review that the file genuinely does not need hot reload. - The pod template must carry
checksum/config. This is the hard requirement of Option B and the only mechanism that does not depend on people. - Structural config is
immutable: truewith a versioned name. Reduces kubelet watch overhead and makes drift visible. - Secrets must have encryption at rest and be injected via volumes, not env. base64 is encoding; env injection is inherited by child processes, lands in dumps, and appears in
kubectl describe. For a hardening checklist, see Related: Kubernetes Security Hardening. - Keep individual ConfigMaps under 200 KiB. The hard ceiling is 1 MiB (inherited from the etcd request size limit), but objects near it slow kubelet sync and pod startup. Split when you exceed it.
- Hot reload must be proven. Only settings that pass a “changes take effect without restart” test may sit on the hot-reload path.
- Every config change gets a rollback drill. Rollback is not just
git revert; confirm the old config works with the new code. I wrote about that separately — see Related: Error Budget Gates.
Rules 5 and 6 are often skipped together. I hit both in one logging-pipeline refactor: the DaemonSet’s Promtail config was mounted via subPath at /etc/promtail/, and after a collection-rule change the cluster-wide log labels stopped updating for two hours without anyone noticing — logs were still flowing, only the labels were wrong. This kind of partial failure is the hardest to catch with monitoring. For the full scenario, see Related: K8s Log Collection Strategies.
Turning the Standard into CI Gates
A standard that lives only in a document is not a standard. Four of the eight rules above are mechanically checkable, and CI is more reliable than review.
The logic is simple; the hard part is that you must scan rendered manifests, not Helm templates or Kustomize sources — subPath may come from a variable, so static source scanning misses it.
#!/usr/bin/env bash
# scripts/ci/check-config-delivery.sh - compliance checks on rendered manifests
# usage: ./check-config-delivery.sh rendered.yaml
set -euo pipefail
MANIFEST="${1:?usage: check-config-delivery.sh <rendered.yaml>}"
FAIL=0
# Rule 1: forbid subPath on configMap/secret volumes within the same pod spec
if yq -e '
.[] | select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet")
| .spec.template.spec as $s
| [($s.volumes // [])[] | select(has("configMap") or has("secret"))] as $cfgvols
| ($s.containers // [])[]
| (.volumeMounts // [])[]
| select(.subPath != null)
| select([$cfgvols[].name] | index(.name))
| .mountPath
' "$MANIFEST" >/dev/null 2>&1; then
if [ "$(yq -e '... | select(.subPath != null) | .subPath' "$MANIFEST" 2>/dev/null | wc -l)" -gt 0 ]; then
echo "FAIL rule 1: subPath mounts a ConfigMap/Secret; hot reload is permanently disabled"
FAIL=1
fi
fi
# Rule 2: workloads referencing a ConfigMap must have the checksum annotation on the pod template
for doc in $(yq -r 'select(.kind == "Deployment") | .metadata.name' "$MANIFEST"); do
if yq -e 'select(.kind == "Deployment") | .spec.template.spec.containers[].envFrom[]?.configMapRef' "$MANIFEST" >/dev/null 2>&1; then
if ! yq -e 'select(.kind == "Deployment") | .spec.template.metadata.annotations | has("checksum/config")' "$MANIFEST" >/dev/null 2>&1; then
echo "FAIL rule 2: $doc references a ConfigMap but the template lacks checksum/config"
FAIL=1
fi
fi
done
# Rule 3: total data per ConfigMap/Secret must not exceed 200 KiB
yq -r 'select(.kind == "ConfigMap" or .kind == "Secret") | [.metadata.name, (.data // {} | to_entries | map(.value | length) | add // 0)] | @tsv' "$MANIFEST" \
| while IFS=$'\t' read -r name bytes; do
if [ "${bytes:-0}" -gt 204800 ]; then
echo "FAIL rule 3: $name is ${bytes}B, above the 200KiB guideline"
FAIL=1
fi
done
exit "$FAIL"
Two remarks on this script.
Rule 1 cannot simply look for “is there a subPath”. subPath on an emptyDir or hostPath is legitimate and common (mounting files an initContainer prepared). Only ConfigMap/Secret volumes are a problem. So first collect volume names that carry configMap/secret, then check whether the subPath mount’s name hits that set.
Rule 2 judges the rendered Deployment document. If your pipeline runs helm template before validation, this holds naturally; if you helm upgrade directly, validate the --dry-run output. I have seen the check attached to the wrong place — validating files under templates/, where checksum/config is a Go template line that yq cannot parse, so the rule always passes and validates nothing.
Rule 3 requires summing the length of each value under data; note that binaryData must be counted separately (it stores base64, so decoded size is roughly 3/4). Skipping this rule is how the node-reboot blocking scenario above happens.
Three things remain review-only: whether hot reload has a proof test, whether a rollback drill was performed, and whether Secrets have encryption at rest. Put those into the launch checklist with a reviewer sign-off — more realistic than cramming them into a script.
Troubleshooting Checklist: Changed but Not Applied
Follow this order and you will usually localize the breakpoint within five minutes.
| Step | Command | What to conclude |
|---|---|---|
| 1. Did the object actually change | kubectl get cm <name> -n <ns> -o yaml | grep -A2 <key> | Wrong value -> wrong object/namespace, or overwritten by another tool |
| 2. How is it mounted | kubectl get deploy <name> -o yaml | grep -A5 volumeMounts | subPath present -> breakpoint one, stop here |
| 3. What does the container see | kubectl exec <pod> -- cat /etc/app/config.yaml | Still old after 90 seconds -> breakpoint one or three |
| 4. Did the inode change | kubectl exec <pod> -- stat -c '%i' /etc/app/config.yaml | Object changed but inode did not -> subPath |
| 5. Does the app re-read | kubectl exec <pod> -- cat /proc/1/environ | tr '\0' '\n' | grep <KEY> | Values injected via env are always the start-time ones |
Two more observations I use regularly:
# Look for the atomic swap: the timestamped dir behind ..data changes once the kubelet has synced
kubectl exec <pod> -- ls -l /etc/app/ | grep '\.\.data'
# Check whether the Deployment rolled because of the config change (Option B took effect)
kubectl get rs -l app=app-api --sort-by=.metadata.creationTimestamp
The second command is especially useful. If kubectl rollout history shows a new revision but the ReplicaSet creation time did not update, the template did not change — Option B is not working and the annotation is in the wrong place.
Also: kubectl get events is essentially empty in this class of problem. Breakpoints one, two, and three produce no events. That is exactly why localization takes so long — every conventional signal is normal. In an internal postmortem I classified these separately as “silent degradation failures”, with the rule: do not start from signals, start from mechanism and walk the checklist above layer by layer.
Lessons from a Real Migration
I once moved 120+ microservices to Kubernetes in three months. Config delivery was the most underestimated part of that effort. There were over 200 ConfigMaps and Secrets, from three historical habits: some services read /opt/app/conf/, some /etc/, some the working directory.
Config-related production issues accounted for nearly half of all failures during the first two weeks, and every one was one of the three breakpoints. If I did it again, I would do two things before migrating.
First, build a config inventory. For every service, record the config source, mount path, whether it supports reload, and whether it is versioned. It sounds like documentation work, but it determines whether the migration can be batched — of 200 services, only 12 genuinely needed hot reload. The rest were simpler as “takes effect on rolling restart”.
Second, write “config takes effect” into acceptance. Add one check to the launch list: change a harmless setting (log level, say) and verify it takes effect within 90 seconds, or that a rollout happened. Three minutes of checking prevents three hours of troubleshooting.
The release-side gain was unambiguous: before, a full deploy took 1.5 hours; afterwards, with our Go scheduler engine, 5 minutes. But that gain depends on config changes entering the release pipeline too. If config still goes through kubectl edit, a 5-minute deploy plus 40 minutes of “why isn’t it applied” is not faster overall.
Summary
- “Changed the config and nothing happened” is never one bug — it is one of three breakpoints: subPath freezing the inode, the app not re-reading the file, and kubelet propagation delay. All three must clear before config truly lands.
- subPath does not update. That has been stable behavior since 2017, marked upstream as “no fix planned”. Files that must hot reload need whole-directory mounts; if you need a single file, use
items, notsubPath. - The atomic writer swaps symlinks, so inotify sees
IN_DELETE_SELF/Rename, notIN_MODIFY. Every hot-reload implementation built on “watch the file’s Write event” is unreliable on mounted volumes. - Make pod restarts a mechanism, not a habit.
checksum/configinside the pod template is the cheapest reliable option. Reloader works if you explicitly enablewatchGlobally, and never stack it with checksum annotations. - Hot reload pays off for very few settings. Structural config belongs in the release pipeline — clean semantics, auditable, rollbackable. Only rotating material (certs, tokens, flags) deserves hot reload, and only with an automated “takes effect without restart” test.
- Lowering
syncFrequencyis the wrong fix. Fifty seconds is not worth cluster-wide API server pressure. What is slow is the process, not the kubelet. - Every conventional signal is normal in this failure class. No events, no failing probes, pods Running the whole time. Start from mechanism and walk the checklist; do not wait for an alert.
One last judgment on selection: if you can only change one thing today, add checksum/config to the pod template. It adds no components, requires no app-level reload support, and is diffable and rollbackable under GitOps — the cheapest and least fragile gate among the three breakpoints.
References & Acknowledgments
This article references the following material. Thanks to the original authors:
- ConfigMap | Kubernetes Documentation — Kubernetes project: volume auto-update semantics, the subPath caveat, the 1 MiB limit and the
immutablefield - ConfigMap | Kubernetes 官方文档(中文) — Kubernetes project: Chinese edition used to cross-check terminology and the note on subPath
- Updating Configuration via a ConfigMap | Kubernetes — Kubernetes project: the official experiment showing environment variables do not follow ConfigMap updates
- ConfigMaps and Secrets mounted with subPath do not update when changed · Issue #50345 — kubernetes/kubernetes community: root-cause discussion and symlink analysis for the subPath mount limitation
- Stakater Reloader repository — Stakater: how the controller works, the two
reload-strategyvalues, and annotation semantics - Coalesce Rollouts When Both Deployment and ConfigMap Are Updated · Issue #992 — stakater/reloader community: full reproduction and analysis of double rollouts on same-batch updates
- When Kubernetes restarts your pod — And when it doesn’t | CNCF — CNCF blog: lab records of kernel-level differences between env and volume consumption
- Kubernetes ConfigMap Hot-Reloading: How kubelet Updates Volumes Atomically — Kubernetes Notes: the timestamped directory and
rename()atomic swap flow of the atomic writer - Kubernetes ConfigMaps: managing application configuration and hot-reload patterns — Jorijn Schrijvershof: practical notes on
IN_DELETE_SELFversusIN_MODIFY, and engineering guidance on ConfigMap sizing