ConfigMaps, Secrets, Helm and Kustomize: update semantics, the subPath trap, rollouts and rollbacks

Env vars from a ConfigMap need a restart; mounted files update in place but only if the app re-reads; subPath mounts never update. A checksum annotation is the reliable answer.

Read the briefing
About 3 min to read 7 drills

What to remember

  1. Three propagation paths, three behaviours. Env needs a restart, mounted files sync in a minute or two, subPath never updates.
  2. Checksum annotation on the pod template. Changes the template hash, so a config change rolls the deployment. This is the standard fix.
  3. A minor chart bump can change rendered manifests. helm diff before, helm get manifest after. Pin the chart version.
  4. Secrets are base64, not encryption. Enable etcd encryption at rest and restrict RBAC, or the Secret is a formality.
  5. Kustomize overlays keep environments honest. One base, per-environment patches — no copy-pasted YAML drifting apart.

The big picture

Configuration on Kubernetes is delivered through ConfigMaps and Secrets, consumed as environment variables or mounted files, and shipped through packaging tools such as Helm and Kustomize. Most configuration incidents are about update semantics: a change that did not reach the process, a mount that silently stopped updating, or a rollout that did not happen because only the ConfigMap changed. Interviewers test whether you know how and when a config change becomes a running-process change.

The mental model

Config has a producer (the object), a transport (env var or volume), and a consumer (the process). Env vars are frozen at container start. Mounted ConfigMap/Secret volumes update in place, eventually, unless you used subPath. Processes rarely re-read files, so "updated on disk" is not "applied". A rollout is the only universal apply mechanism, and it happens only when the pod template changes, which a ConfigMap edit does not do.

In depth

Env vars versus mounted files, and the subPath trap

A ConfigMap or Secret can be consumed as environment variables (envFrom, valueFrom) or as a volume. Env vars are read once when the container starts; changing the ConfigMap changes nothing until the pod is recreated. Volume mounts are projected by the kubelet and refreshed on its sync period (about a minute, plus cache TTL), so files on disk change without a restart, though the process must re-read them (SIGHUP, a watcher, or a config reloader sidecar).

subPath breaks that: a subPath mount copies a single file at pod start and is never updated. Teams use subPath to place one file into an existing directory without hiding its other contents, then wonder why config changes 'do not work'. Alternatives: mount the whole ConfigMap into a dedicated directory and symlink or point the app at it, or use items with path to control filenames while still mounting a directory.

Immutable config and rollouts on change

immutable: true on a ConfigMap or Secret forbids edits (you must create a new object), protects against accidental in-place changes to a running fleet, and reduces API server watch load in large clusters. It pairs naturally with a rollout-on-change pattern: name or hash the ConfigMap by content (Kustomize's configMapGenerator does this; Helm charts do it with checksum/config annotations on the pod template), so a config change produces a new object name, the pod template changes, and the Deployment rolls. Without that, editing a ConfigMap in place leaves running pods on the old env vars, and a later unrelated rollout picks up the new config at a surprising time.

Helm and Kustomize: what each one is for

Kustomize is patch-based: a base of plain manifests plus overlays that patch fields per environment, with generators for ConfigMaps/Secrets that append content hashes. It is built into kubectl (kubectl apply -k), has no templating language, and shines for your own applications across environments. Helm is template-based packaging: a chart renders manifests from values.yaml, tracks releases with revision history (helm history, helm rollback), and is the distribution format for third-party software (ingress-nginx, cert-manager, Prometheus). Its costs are templating complexity and hidden defaults in values files; pin chart versions, read helm template output before installing, and treat helm upgrade --install as a deploy with a rollback plan.

Myths and facts

Myth: Editing a ConfigMap updates the running pods.

Fact: Env vars never update; volume mounts update eventually but the process must re-read; subPath mounts never update. Only a pod template change triggers a rollout.

Myth: Secrets are safer than ConfigMaps because they are encrypted.

Fact: Both are plaintext in etcd unless encryption at rest is enabled; Secrets get RBAC separation and are not shown by default, that is all.

Myth: Helm and Kustomize are competitors; pick one.

Fact: Most teams use Helm for third-party charts and Kustomize (or Helm) for their own apps; kubectl can even render Helm charts through Kustomize.

Myth: helm rollback restores the previous ConfigMap content everywhere.

Fact: It re-applies the previous release's manifests; anything changed outside Helm (kubectl edit) is not tracked.

Myth: Immutable ConfigMaps make config changes impossible.

Fact: They make changes explicit: create a new object and roll the pod template to reference it.

How pros do it

  • Prefer mounted files over env vars for anything that changes; give the process a reload mechanism or a reloader sidecar.
  • Avoid subPath for ConfigMap and Secret mounts unless you accept that the file never updates.
  • Hash config into the pod template (checksum annotation or generated names) so config changes roll out deliberately.
  • Mark production ConfigMaps and Secrets immutable and version them by name.
  • Pin Helm chart versions, review rendered manifests, and keep values files in git with a rollback runbook.

Questions people ask

I changed a ConfigMap but the app still uses the old value. Why?

Ask back how it is consumed, then answer in three parts: an env var is a snapshot at container start, so the pod must be recreated; a subPath mount is copied once and never updates; a plain volume mount updates within about a minute, but only if the process re-reads the file. Finish with the fix: hash the config into the pod template so the change rolls out on purpose.

How do I make a Deployment restart when its ConfigMap changes?

Put a checksum of the config in a pod template annotation (Helm) or use a generated ConfigMap name (Kustomize configMapGenerator) so the template changes; or use a reloader controller.

How do I see what Helm will change before upgrading?

helm diff upgrade (plugin) or render with helm template and compare; always read the chart's changelog for major bumps.

Where do secrets come from in a GitOps setup?

From a secrets manager via an operator (External Secrets, Vault agent) or sealed/encrypted secrets in git; never plaintext values files.

Should I template everything in Helm?

Template what varies by environment; hard-code what does not. Over-templated charts are the main source of Helm pain.

Further reading

Drills · 7

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

'I edited the ConfigMap and the app still has the old value — why?' The Deployment consumes it through envFrom, and the engineer changed it with kubectl edit. When do the running pods see the new values?

  1. Within about a minute, when the kubelet syncs. That is the behaviour of volume mounts, not env vars.
  2. Immediately; the API server pushes the change. Nothing pushes into a process's environment.
  3. Never, until the pods are recreated: environment variables are read once at container start. Env vars are a snapshot taken when the container is created.
  4. On the next liveness probe. Probes check health; they do not reload configuration.
In short

Never; environment variables are read once at container start, so the pods must be recreated.

Why

The transport determines the update semantics. Env vars: at start only. Volumes: eventually, in place. subPath volumes: never. That is the whole topic in three sentences, and interviewers ask it because so many incidents come from expecting env vars to change.

The common mistake

Answering 'within a minute when the kubelet syncs'. That is the volume behaviour; nothing ever rewrites a running process's environment.

Read the docs

2 Answer out loud

A new engineer asks: 'I changed the ConfigMap, why didn't my app change?' Explain the three ways config reaches a container and what each means for updates, then describe how you would make config changes roll out deliberately. Four to six sentences.

In short

A strong answer says env vars never update, mounted files update in about a minute, subPath never updates, and a config hash in the pod template makes changes roll out.

What a strong answer does
  • mechanism: All three with timing (start, ~1 min kubelet sync + process reload, never), plus the fact that a ConfigMap edit does not change the pod template.
  • deliberate rollout: Hash config into the template (Kustomize generator or Helm checksum), immutable objects, rollout history for rollback, or a reloader for live knobs; states the tradeoff.
  • communication: Plain, ordered, ends with the recommendation.
Why

The three transports with their update semantics, plus one deliberate-rollout mechanism, is the complete answer; the subPath detail separates people who have debugged this from people who have read about it.

The common mistake

Offering 'restart the pods' as the mechanism. A manual restart leaves no trace in rollout history; the deliberate answer is a template change (hash or checksum annotation) so the rollout happens by mechanism and can be rolled back.

3 Pick the strongest answer

An nginx pod mounts a ConfigMap key as /etc/nginx/conf.d/app.conf using subPath: app.conf so the rest of conf.d stays intact. The team updates the ConfigMap, waits ten minutes, and the file has not changed. Why?

  1. nginx caches the file; send SIGHUP. A reload would be needed after the file changes, but the file itself never changed.
  2. The kubelet sync period is longer than ten minutes. Normal ConfigMap volumes update within roughly a minute.
  3. subPath mounts copy the file once at pod creation and are never updated by the kubelet. This is documented behaviour: subPath volumes do not receive ConfigMap updates.
  4. ConfigMaps larger than 1 MiB do not update. A ConfigMap can never exceed 1 MiB, on create or update; size has nothing to do with whether a mount refreshes.
In short

A subPath mount copies the file once at pod start and the kubelet never updates it.

Why

The subPath trap: convenient for placing one file among others, fatal for updatability. Mount the whole ConfigMap into /etc/nginx/conf.d/ (using items to name files) and keep static files in the image or another mount, then reload nginx on change.

Read the docs

4 Read the output

What does the second apply print, and what happens to the pods?

# kustomization.yaml
resources: [deployment.yaml]
configMapGenerator:
  - name: api-config
    literals:
      - LOG_LEVEL=info

$ kubectl apply -k .
configmap/api-config-7g5k2h8f9d created
deployment.apps/api created

# edit: LOG_LEVEL=debug
$ kubectl apply -k .
  1. A new ConfigMap with a different hash suffix is created and the Deployment is configured; the pod template now references the new name, so a rolling update starts. configMapGenerator appends a content hash to the name and rewrites references, turning a config change into a template change.
  2. configmap/api-config-7g5k2h8f9d configured; pods keep running with the old value until restarted. The generator never edits in place; a new name means a new object.
  3. Nothing changes because Kustomize only manages the Deployment. The generator is exactly the part that manages the ConfigMap.
  4. An error, because the ConfigMap already exists. Different content means a different name; no conflict.
In short

A new ConfigMap with a new hash suffix is created, the Deployment is updated to point at it, and a rolling update starts.

Why

The hash suffix is the mechanism that makes config changes deliberate rollouts. Old ConfigMaps remain (prune them with kubectl apply -k --prune or a label-based cleanup) so a rollback to the previous ReplicaSet still finds its config.

Read the docs

5 Find what's broken

Operators need to change maxLagSlots during incidents and see it applied within a minute. This manifest makes that impossible in three different ways. Which lines?

apiVersion: v1
kind: ConfigMap
metadata:
  name: gateway-config
immutable: true
data:
  gateway.yaml: |
    upstreams: [rpc-a, rpc-b]
    maxLagSlots: 50
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway
spec:
  replicas: 3
  selector:
    matchLabels: { app: gateway }
  template:
    metadata:
      labels: { app: gateway }
    spec:
      containers:
        - name: gateway
          image: registry.example.com/gateway:2.4.0
          env:
            - name: MAX_LAG_SLOTS
              valueFrom:
                configMapKeyRef:
                  name: gateway-config
                  key: maxLagSlots
          volumeMounts:
            - name: cfg
              mountPath: /etc/gateway/gateway.yaml
              subPath: gateway.yaml
      volumes:
        - name: cfg
          configMap:
            name: gateway-config
In short

The three blockers are immutable: true (line 5), the env var (line 27), and the subPath mount (line 34).

What's broken
  • Line 5: immutable: true forbids editing the ConfigMap in place; every change requires a new object and a pod template change.
  • Line 27: The value is consumed as an environment variable, which never updates without a pod restart; also the key maxLagSlots does not exist as a top-level ConfigMap key (the data is inside gateway.yaml).
  • Line 34: subPath mount: the file is copied once at pod start and never updated.
Why

Three layers all fight the requirement: immutability blocks the edit, the env var freezes the value, and subPath freezes the file. For incident-time tuning, the design is a directory mount plus a process that reloads, or a rollout-on-change workflow if restarts are acceptable.

Read the docs

6 Scenario: what do you do next?

A helm upgrade of the ingress-nginx chart (minor version bump, values unchanged) completed, and five minutes later all external traffic returns 404. kubectl get pods -n ingress-nginx shows the controller pods Running and Ready. The upgrade was run from a laptop.

Step 1. First move?

  1. Delete and reinstall the chart. Destroys release history and the LoadBalancer IP may change.
  2. Read the chart's changelog to understand the change. Right later; users are seeing 404s now.
  3. helm rollback ingress-nginx <previous revision> to restore service, then diff the two rendered releases (helm get manifest for both revisions) to find what changed. Helm tracks release history precisely so that mitigation is one command; investigation follows on the diff.
  4. Restart the controller pods. They are healthy; the behaviour changed, not their state.

Step 2. Rollback fixes it. The diff shows the new chart version changed the default IngressClass name and no longer watches ingresses without an explicit ingressClassName. What is the fix forward?

  1. Pin the chart at the old version forever. Freezes security fixes; the fix is a values change.
  2. Set the chart values to keep the class name (or mark it default), verify with helm diff/helm template against a staging cluster, then upgrade again. Addresses the actual change explicitly and verifies before repeating the upgrade.
  3. Add ingressClassName to all 200 Ingress objects tonight. A valid long-term cleanup, but a values change restores compatibility now without a fleet-wide edit under pressure.
  4. Switch to Kustomize for ingress-nginx. The tool did not cause the incident; an unreviewed upgrade did.

Step 3. Systemic fix?

  1. Only upgrade charts once a year. Bigger, riskier jumps; the problem was review, not frequency.
  2. Upgrades of platform charts go through CI: pinned versions in git, helm diff posted on the PR, a staging cluster smoke test, and release notes read for major/minor bumps; no upgrades from laptops. Turns chart upgrades into reviewed, verified changes with a paper trail.
  3. Give the platform team exclusive helm access. Access control does not add verification.
In short

Run helm rollback first to restore traffic, then diff the two rendered releases to find what the chart changed.

Why

Helm's release history is its strongest operational feature: rollback is cheap and the manifest diff is exact. The interview shape: mitigate with rollback, diagnose from the rendered diff, fix via values with verification, then move upgrades into a reviewed pipeline.

Read the docs

7 Quick recall

A helm upgrade was interrupted and the release now sits in pending-upgrade; every further helm upgrade fails with 'another operation is in progress'. Which Helm command gets you out?

In short

helm rollback to the last deployed revision clears a release stuck in pending-upgrade.

Accepted

helm rollback · rollback · helm rollback <release> <revision>

Why

helm rollback <release> <last deployed revision>: it writes a new deployed revision from the last good one and marks the stuck revision superseded, after which upgrades work again; helm history shows which revision was last deployed. Deleting the pending release Secret by hand is the blunt alternative.

Next lesson CoreDNS and service discovery: ndots, search domains, headless Services, DNS policy
Drill · ConfigMaps, Secrets, Helm and Kustomize
0:00

Loading…