This scenario demonstrates:
✔ ConfigMap mounted as a file
✔ Pod picks up changes automatically without restart
✔ Application reads updated data from the file in real time
✔ You verify live updates
This is how apps like Nginx, Prometheus, and Spring Boot use dynamic config reloads.
🟩 Step 1 — Create a ConfigMap
Create dynamic-configmap.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: dynamic-config
data:
message: "Hello from ConfigMap v1"
Apply it:
kubectl apply -f dynamic-configmap.yaml
🟩 Step 2 — Create a Pod That Mounts the ConfigMap as a File
Create pod-dynamic-config.yaml:
apiVersion: v1
kind: Pod
metadata:
name: dynamic-config-pod
spec:
containers:
- name: demo-container
image: busybox
command: ["sh", "-c", "while true; do echo \"Message: $(cat /config/message)\"; sleep 3; done"]
volumeMounts:
- name: config-volume
mountPath: /config
volumes:
- name: config-volume
configMap:
name: dynamic-config
Apply it:
kubectl apply -f pod-dynamic-config.yaml
Wait for ready:
kubectl wait --for=condition=Ready pod/dynamic-config-pod --timeout=60s
🟩 Step 3 — View Live Output From the Pod
Open logs:
kubectl logs -f dynamic-config-pod
You will see:
Message: Hello from ConfigMap v1
Message: Hello from ConfigMap v1
...
Keep this logs window open.
🟩 Step 4 — Update the ConfigMap Without Restarting the Pod
Edit the ConfigMap:
kubectl edit configmap dynamic-config
Change the value:
message: "Hello from ConfigMap v2 - UPDATED LIVE"
Save & exit.
🟩 Step 5 — Watch the Pod Update Automatically (NO Restart Needed)
Your logs will automatically switch:
Message: Hello from ConfigMap v1
Message: Hello from ConfigMap v1
Message: Hello from ConfigMap v2 - UPDATED LIVE
Message: Hello from ConfigMap v2 - UPDATED LIVE
✔ No pod restart
✔ No rollout
✔ No manual intervention
💡 WHY does this work?
| Method | Auto-Update? | Reason |
|---|---|---|
| ConfigMap → env variables | ❌ No | Env vars are fixed at Pod startup |
| ConfigMap → mounted volume | ✅ Yes | Kubelet updates file symlink every ~1–2 seconds |
Kubernetes mounts each ConfigMap entry as a file using a symlink that is automatically refreshed.
⚠️ IMPORTANT NOTE
Although the file updates automatically:
➡ Your application must reload the file dynamically
➡ If the app loads config only at startup, you won’t see updates
🌟 Thanks for reading! If this post added value, a like ❤️, follow, or share would encourage me to keep creating more content.
— Latchu | Senior DevOps & Cloud Engineer
☁️ AWS | GCP | ☸️ Kubernetes | 🔐 Security | ⚡ Automation
📌 Sharing hands-on guides, best practices & real-world cloud solutions



Top comments (0)