Resolve ContainerCreating Issue Caused by Missing ConfigMap
Scenario
A Deployment named web-hydrogen is running in the hydrogen namespace with 2 replicas, but both Pods are stuck in ContainerCreating state and never reach Running. Users trying to reach the application get nothing — the NodePort doesn't respond.
The Deployment mounts a ConfigMap as a volume to serve a static HTML page, but that ConfigMap was never created. The source file for the page is already on dev-machine:
/home/laborant/web-hydrogen.html
Task
- Create a ConfigMap named
configmap-web-hydrogen-htmlin thehydrogennamespace from/home/laborant/web-hydrogen.html, storing its content under the keyindex.html - Make sure the existing Pods actually pick up the fix — check whether they recover automatically or need to be restarted
- Confirm the application responds successfully on NodePort
30099
# Test application
curl http://cplane-01:30099
Hint 1 — Diagnose the Stuck Pods
Check the Pod status and look at the events to find the exact failure reason:
kubectl get pods -n hydrogen
kubectl describe pod -n hydrogen -l app=web-hydrogen
Look in the Events section near the bottom of the describe output, and check
the Volumes section to see what resource the Pod is trying to mount.
Documentation
Hint 2 — Create the ConfigMap from a File with a Custom Key
Use kubectl create -h and kubectl create configmap -h to discover how to
create a ConfigMap from a file while setting a custom key name — the key does
not have to match the source filename.
The file /home/laborant/web-hydrogen.html needs to become a ConfigMap named
configmap-web-hydrogen-html in the hydrogen namespace, with its content
stored under the key index.html.
Documentation
Hint 3 — Existing Pods May Not Recover on Their Own
Creating the ConfigMap does not always make the already-stuck Pods recover
immediately — kubelet retries failed mounts on a backoff schedule, which can
take a while. If the Pods don't transition to Running shortly after the
ConfigMap is created, force a fresh rollout:
kubectl rollout restart deployment web-hydrogen -n hydrogen
Once running, verify the Service has endpoints and the app responds:
kubectl get endpoints web-hydrogen-service -n hydrogen
curl http://cplane-01:30099
Documentation