Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 81/ 160
05. Configuration, Packaging & GitOps

ConfigMaps: Decoupling Configuration from Container Images

Keep non-secret config out of images using ConfigMaps referenced by pods.

BeginnerConfigMap · Decoupling · Config3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

A ConfigMap is the labeled settings sheet included with a packaged appliance rather than soldered into its circuit board. The simple Kubernetes rule is: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Think of it like…

A ConfigMap is the labeled settings sheet included with a packaged appliance rather than soldered into its circuit board.

Where you’ve seen it

A platform team reviews a promoted source revision and runs kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml. Expected evidence: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags. If the run instead shows this symptom, stop and restore the last known state: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.

Words you’ll hear

ConfigMap
For this lesson, ConfigMap is the controlling idea: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.
Decoupling
Decoupling is the checkpoint; run kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml and inspect the owner chain. Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.
Config
Config is the outcome to preserve; the cost is explicit: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.
Verification evidence
The evidence command is kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml. It connects the declaration to this behavior: Keep non-secret config out of images using ConfigMaps referenced by pods.

Visual diagram

Loading interactive diagram

Theory & deep dive

How ConfigMap reaches the intended state

Keep non-secret config out of images using ConfigMaps referenced by pods. A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

The concrete checkpoint is kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml; compare the ConfigMap owner, Decoupling state, and Config outcome instead of treating YAML acceptance as proof.

Verify Decoupling, not only object creation

Run kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml after the change and correlate the result with Events and the owning object. A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Key takeaway: ConfigMap is implemented only when this invariant remains observable: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Decoupling: failure boundary and production cost

Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values. The prerequisite contract is concrete: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency. A safe design limits blast radius, records the last good configuration, and uses kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml as a deterministic rollback checkpoint.

Recover from Decoupling drift

Capture the current state with kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.

Key takeaway: Accept the trade-off consciously: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.

How it works, step by step

Step 1 of 4
Source author

1. Choose the source of truth

Version the source and describe the review, render, and reconciliation boundary: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

ConfigMap contract → owned state
Key numbers at this step
Goal
Keep non-secret config out of images using ConfigMaps referenced by pods.
Owner
ConfigMap

When to use it & trade-offs

What it is

Keep non-secret config out of images using ConfigMaps referenced by pods. A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Why it matters: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values. The invariant at risk is specific: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags. The quickest fact check before changing the design is kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml.

When to reach for it

  • Use ConfigMap to enforce this invariant: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.
  • Use Decoupling evidence from kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml in reviews and incident timelines. Keep non-secret config out of images using ConfigMaps referenced by pods.
  • Choose the platform operator workflow route only when this cost is justified by governance or scale: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.

When to avoid or be careful

  • Avoid assuming ConfigMap is complete after YAML submission; the required behavior is concrete: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.
  • Avoid treating the next symptom as random; check the owner and state with kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml first: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.

Native, manual, and managed paths for ConfigMap

Versioned declarative source
Best for: Keep non-secret config out of images using ConfigMaps referenced by pods. A concrete incident check is kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml.

Strengths: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Watch out: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency. Recovery must also recognize this signal: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.

Imperative cluster edit
Best for: Quickly testing the Decoupling assumption with kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml; the expected invariant is: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Strengths: kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike ConfigMap, it does not make this symptom self-documenting: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.

Platform operator workflow
Best for: Teams that need Config integrated with guardrails; the evidence path is kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.

Watch out: The added platform ownership buys value at this cost: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.
  • Trace ConfigMap to Config through Decoupling; the invariant is: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.
  • Recognize the symptom: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.
  • Justify the cost: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.
  • Verify with kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml instead of only inspecting YAML.

Benchmarks & rules of thumb

1MiB -
standard Kubernetes object size limit constrains one ConfigMap
2 -
data forms are string data and binaryData
0 -
automatic encryption of confidential values

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the ConfigMap owner contract: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags.
  • Ignoring this telltale condition leads to unrelated changes: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values.
  • Repeating kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml without an owner for remediation wastes retry cost. Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags?
  • Which owner object, logs, and Events would you inspect for this symptom-Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values-?
  • At what threshold would this cost become unacceptable: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency?
Interview tip: Interview sequence: state the invariant, run kubectl create configmap api-config --from-file=application.yaml; kubectl get configmap api-config -o yaml, name the failure, then justify the cost. Invariant: A ConfigMap stores non-secret UTF-8 configuration or binaryData outside the image so the same artifact can run with different endpoints and feature flags. Failure: Storing passwords in a ConfigMap exposes them through normal read permissions, and updating one does not automatically rebuild a process's environment or cached values. Cost: Decoupling configuration speeds rollout, but invalid flags, key growth, and mutable runtime settings create a separate versioned dependency.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply ConfigMaps: Decoupling Configuration from Container Images with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Data Persistence Patterns for Vector Databases & LLM Model Weights
Next topic
Injecting ConfigMaps as Environment Variables vs Mounted Files