Bird
Raised Fist0
Kubernetesdevops~20 mins

Updating ConfigMaps and propagation in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
ConfigMap Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Effect of Updating a ConfigMap on Mounted Volumes

You have a pod with a ConfigMap mounted as a volume. You update the ConfigMap using kubectl apply. What happens to the files inside the pod's mounted volume immediately after the update?

Kubernetes
kubectl apply -f updated-configmap.yaml
AThe files inside the pod's mounted volume update immediately without restarting the pod.
BThe files inside the pod's mounted volume do not change until the pod is restarted.
CThe pod automatically restarts to apply the updated ConfigMap files.
DThe ConfigMap update fails if the pod is running.
Attempts:
2 left
💡 Hint

Think about how Kubernetes handles ConfigMap volumes and file updates inside running pods.

🧠 Conceptual
intermediate
1:30remaining
Propagation Delay of ConfigMap Updates to Pods

After updating a ConfigMap, how long does it typically take for the changes to appear inside a pod's mounted volume?

AOnly after the pod is restarted manually or automatically.
BImmediately, within milliseconds.
CWithin a few seconds, usually less than a minute.
DAfter the ConfigMap is deleted and recreated.
Attempts:
2 left
💡 Hint

Consider the Kubernetes sync interval for ConfigMap volume updates.

❓ Troubleshoot
advanced
2:30remaining
Why Are ConfigMap Updates Not Visible in a Pod?

You updated a ConfigMap, but the pod still shows old values in the mounted files. What is the most likely reason?

AThe pod uses environment variables from the ConfigMap, which do not update automatically.
BThe ConfigMap was updated but not applied with <code>kubectl apply</code>.
CThe pod has a volume mount but the ConfigMap key names do not match the file names.
DThe ConfigMap volume mount is read-only and cannot update files.
Attempts:
2 left
💡 Hint

Think about how ConfigMap updates propagate differently for environment variables versus volume mounts.

🔀 Workflow
advanced
3:00remaining
Updating a ConfigMap and Ensuring Pod Uses New Values

You want to update a ConfigMap and ensure a deployment's pods use the new values immediately. Which sequence of commands achieves this?

Akubectl delete configmap myconfig; kubectl create -f configmap.yaml
Bkubectl apply -f configmap.yaml; kubectl rollout restart deployment/myapp
Ckubectl edit configmap myconfig; kubectl scale deployment/myapp --replicas=0; kubectl scale deployment/myapp --replicas=3
Dkubectl apply -f configmap.yaml; kubectl delete pod -l app=myapp
Attempts:
2 left
💡 Hint

Consider the recommended way to restart pods in a deployment after ConfigMap changes.

✅ Best Practice
expert
4:00remaining
Best Practice for Managing ConfigMap Updates in Production

In a production environment, what is the best practice to safely update ConfigMaps and ensure pods use the new configuration without downtime?

AUpdate the ConfigMap and immediately delete all pods to force recreation.
BCreate a new ConfigMap with a different name and update the deployment to use it without restarting pods.
CEdit the ConfigMap directly inside the cluster and wait for pods to pick up changes automatically.
DUse <code>kubectl apply</code> to update the ConfigMap and perform a rolling restart of the deployment.
Attempts:
2 left
💡 Hint

Think about zero downtime and controlled rollout strategies.

Practice

(1/5)
1. What happens when you update a ConfigMap in Kubernetes without restarting the pods using it?
easy
A. Pods continue using the old ConfigMap values until restarted
B. Pods automatically reload the new ConfigMap values immediately
C. Kubernetes deletes the pods using the old ConfigMap
D. ConfigMap update fails if pods are running

Solution

  1. Step 1: Understand ConfigMap behavior on update

    Updating a ConfigMap does not notify or refresh pods automatically.
  2. Step 2: Effect on running pods

    Pods keep using the old ConfigMap data until they are restarted or redeployed.
  3. Final Answer:

    Pods continue using the old ConfigMap values until restarted -> Option A
  4. Quick Check:

    Pods do not auto-refresh ConfigMaps = B [OK]
Hint: Pods need restart to use updated ConfigMaps [OK]
Common Mistakes:
  • Assuming pods auto-refresh ConfigMap changes
  • Thinking ConfigMaps update triggers pod restart automatically
  • Believing ConfigMap updates delete pods
2. Which command correctly updates a ConfigMap named app-config from a file config.yaml?
easy
A. kubectl update configmap app-config --from-file=config.yaml
B. kubectl edit configmap app-config --from-file=config.yaml
C. kubectl replace configmap app-config --from-file=config.yaml
D. kubectl create configmap app-config --from-file=config.yaml --dry-run=client -o yaml | kubectl apply -f -

Solution

  1. Step 1: Understand updating ConfigMap from file

    Direct update requires creating new YAML and applying it.
  2. Step 2: Use dry-run and apply for update

    Command C creates new ConfigMap YAML from file and applies it, updating existing ConfigMap.
  3. Final Answer:

    kubectl create configmap app-config --from-file=config.yaml --dry-run=client -o yaml | kubectl apply -f - -> Option D
  4. Quick Check:

    Use create with dry-run + apply to update ConfigMap = C [OK]
Hint: Use create with dry-run and apply to update ConfigMap [OK]
Common Mistakes:
  • Using 'kubectl update' which is not a valid command
  • Trying to edit ConfigMap with --from-file option
  • Using replace without proper YAML input
3. Given a pod using a ConfigMap mounted as a volume, what is the output of cat /etc/config/app.properties inside the pod immediately after updating the ConfigMap but before restarting the pod?
medium
A. Shows the updated content from the ConfigMap
B. Shows the old content from the ConfigMap before update
C. File is empty because ConfigMap is not mounted
D. Command returns an error because ConfigMap changed

Solution

  1. Step 1: Understand ConfigMap volume mount behavior

    ConfigMap mounted as volume is projected as files inside pod at start time.
  2. Step 2: Effect of ConfigMap update on mounted files

    Files inside pod do not update automatically; they keep old content until pod restart.
  3. Final Answer:

    Shows the old content from the ConfigMap before update -> Option B
  4. Quick Check:

    Mounted ConfigMap files do not auto-update = A [OK]
Hint: Mounted ConfigMap files update only after pod restart [OK]
Common Mistakes:
  • Assuming mounted files auto-refresh on ConfigMap update
  • Expecting empty files if ConfigMap changed
  • Thinking command errors due to ConfigMap update
4. You updated a ConfigMap but your pods still use old values. Which command fixes this without deleting pods manually?
medium
A. kubectl rollout restart deployment/myapp
B. kubectl delete pod -l app=myapp
C. kubectl apply -f configmap.yaml
D. kubectl configmap refresh myapp

Solution

  1. Step 1: Identify how to refresh pods after ConfigMap update

    Pods must restart to load new ConfigMap values.
  2. Step 2: Use rollout restart to restart pods gracefully

    Command 'kubectl rollout restart' triggers pod restart without manual deletion.
  3. Final Answer:

    kubectl rollout restart deployment/myapp -> Option A
  4. Quick Check:

    Use rollout restart to refresh pods = D [OK]
Hint: Use rollout restart to refresh pods after ConfigMap update [OK]
Common Mistakes:
  • Deleting pods manually instead of rollout restart
  • Expecting apply to restart pods automatically
  • Using non-existent commands like configmap refresh
5. You have a deployment using a ConfigMap for environment variables. After updating the ConfigMap, you want all pods to use the new values without downtime. What is the best approach?
hard
A. Update the ConfigMap and wait; pods auto-refresh environment variables
B. Delete all pods manually to force recreation with new ConfigMap
C. Update the ConfigMap and run kubectl rollout restart deployment/myapp
D. Edit each pod to mount the new ConfigMap version

Solution

  1. Step 1: Understand environment variable update behavior

    Pods do not auto-refresh environment variables from ConfigMap updates.
  2. Step 2: Use rollout restart for zero downtime update

    Rolling restart updates pods one by one, applying new ConfigMap values without downtime.
  3. Final Answer:

    Update the ConfigMap and run kubectl rollout restart deployment/myapp -> Option C
  4. Quick Check:

    Rollout restart updates pods gracefully = A [OK]
Hint: Use rollout restart for zero downtime ConfigMap update [OK]
Common Mistakes:
  • Expecting pods to auto-refresh env vars
  • Deleting pods causing downtime
  • Editing pods directly which is not recommended
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard