Pcornel
Browse topics
Options
Recent
Favorites
Containers · Technical reference

ConfigMaps

Direct answer

ConfigMaps store non-secret configuration as key/value data, consumed as environment variables or mounted files.

When to use this

Use it to externalise configuration, or when a pod does not pick up a change.

First 30 seconds

1. kubectl get cm <c> -o yaml.

2. Referenced correctly in the pod?

3. Inside the pod: env/file value.

4. Restart: kubectl rollout restart.

5. Avoid subPath if live updates needed.

Operational verification

ConfigMap → referenced by pod → env/file in container

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Docker / containerd / Podman / Kubernetes / OCI-compatible platforms
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformDocker / containerd / Podman / Kubernetes / OCI-compatible platforms
Scope / prerequisiteUse it to externalise configuration, or when a pod does not pick up a change.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 How to verify Verify boundary

Compare the ConfigMap content with what the container sees. After a change, restart Pods that use environment variables. Use a hash annotation in the Pod template to trigger rollouts automatically.

Step 2 Common failures Narrow the fault

Putting passwords in a ConfigMap exposes them to anyone who can read ConfigMaps. A missing key referenced by envFrom without optional: true stops the container from starting. subPath mounts keep the old content forever.

Key points

Env vars are fixed at container start — restart to apply. Mounted files update after a delay (not with subPath). Use versioned names or checksum annotations to trigger rollouts.

Key checks
  • kubectl get cm <c> -o yaml — first check for this topic
  • kubectl get pods -o wide — pods, status, node, IP
  • kubectl describe pod <pod> — events and conditions
  • kubectl logs <pod> [-c <c>] [--previous] — container logs (incl. previous crash)
  • kubectl get events --sort-by=.lastTimestamp — recent cluster events
ReferenceWhat it is1 section · depth on demand

How it works

The kubelet projects ConfigMap data into the Pod as files or reads it when building the container environment. File projections are refreshed periodically through a symlink swap, so applications must re-read files to notice changes.

ReferenceImportant terms & boundaries3 sections · depth on demand

Using ConfigMaps

kubectl create configmap app-config --from-file=app.yaml --from-literal=LOG_LEVEL=info
kubectl get cm app-config -o yaml

Consume as env vars (envFrom) or mounted files. Mounted files update automatically (after a delay); env vars need a Pod restart (kubectl rollout restart). Limit 1 MiB per ConfigMap. Use immutable: true for large static configs to reduce API load.

In depth

How a change reaches the application

ConsumptionUpdated in a running Pod?Pickup
Environment variables (env, envFrom)NoRestart Pods (kubectl rollout restart)
Volume mount (whole ConfigMap)Yes, after kubelet sync (typically under a minute or two)App must re-read the file or watch it
Volume mount with subPathNoRestart Pods
immutable: trueCannot changeCreate a new ConfigMap name and roll out

Files from a volume are swapped atomically through a ..data symlink, so an app watching the file should watch the directory or re-open the path, not keep the old file descriptor.

Rolling out on config change

Put a hash of the configuration in the Pod template so a changed ConfigMap triggers a normal rolling update:

template:
  metadata:
    annotations:
      checksum/config: "{{ sha256 of app.yaml }}"   # set by Helm, Kustomize or CI

Kustomize's configMapGenerator does the same by appending a content hash to the ConfigMap name.

Worked check — what does the container really see?

kubectl get cm app-config -o jsonpath='{.data.app\.yaml}' | head
kubectl exec deploy/web -- cat /etc/app/app.yaml | head
kubectl exec deploy/web -- printenv LOG_LEVEL

A ConfigMap is limited to 1 MiB and is not encrypted; credentials belong in a Secret.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • Expecting pods to reload ConfigMaps automatically.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
configmapskubernetes configmapconfigmap reload
Confirmation

Confirm action

Continue?