World map

 

BM: Baca dalam Bahasa Melayu

World K4: Notes, Lockers & Packages

ConfigMaps: notes on the wall

You will learn: to keep settings in a ConfigMap and read them as env vars or as files.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

You are here: cluster kind-dev namespace default
kubectl exec runs printenv GREETING inside the shop tray. It prints Selamat datang. Terminal output: $ kubectl exec deploy/shop -- printenv GREETING Selamat datang

Your shop greets everyone with Selamat datang. The boss wants Jemput makan. Bake a new image for two words? There is a calmer way.

Watch

Tap the two settings on the note.

0 of 2 found

A note on the stall wall holds the settings. The cook reads it, and the recipe never changes. In Kubernetes, that note is a ConfigMap: A note on the stall wall: settings the app reads, kept outside the image..

Try it

Pin up the note from the terminal. Then open the shop.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 0 (0 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen

No trays here.

dev-worker2Open

No trays here.

Time: +0s (sped up)

Watch

Tap the lines that turn the note into env vars.

0 of 3 found

The tray reads the note two ways. envFrom makes each line an environment variable. The volume makes each line a file in /etc/notes.

Try it

Read the note both ways. First the env var, then the file.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 1 (1 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • shop·cprxv
dev-worker2Open

No trays here.

Time: +0s (sped up)

Predict

You change the note to Jemput makan. You wait two minutes. What does the tray see?

Pick one answer.

Check

You are here: cluster kind-dev namespace default
The new note is applied. Two minutes later, the file says Jemput makan, but printenv still says Selamat datang. Terminal output: $ kubectl apply -f settings-v2.yaml configmap/settings configured $ sleep 120 $ kubectl exec deploy/shop -- cat /etc/notes/GREETING Jemput makan $ kubectl exec deploy/shop -- printenv GREETING Selamat datang

The file caught up. The env var did not. Restart the trays to read it again: kubectl rollout restart deployment/shop.

Check

Sort each fact: env var or file?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now read settings from a ConfigMap, two ways.

      Go deeper (optional)

      A ConfigMap holds up to 1 MiB. It is not secret: anyone who can read ConfigMaps sees it. A file mounted with subPath never updates. immutable: true stops changes by accident.

      Real rep (optional), on a practice kind cluster only:

      Real mission

      1. kubectl config current-context
      2. kubectl create configmap settings --from-literal=GREETING=Hai
      3. kubectl create deployment shop --image=nginx:1.29-alpine
      4. kubectl set env deployment/shop --from=configmap/settings
      5. kubectl exec deploy/shop -- printenv GREETING
      6. kubectl delete deployment/shop configmap/settings

      0 of 6 steps done · Your ticks are saved.