Pod stuck in ContainerCreating: find the blocked step
Reproduced on k3s v1.31.5 (k3d) with kubectl v1.36.1.
What you see
$ kubectl get pod stuck-demo -n lab
NAME READY STATUS RESTARTS AGE
stuck-demo 0/1 ContainerCreating 0 2m35s
$ kubectl describe pod stuck-demo -n lab
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 2m35s default-scheduler Successfully assigned lab/stuck-demo to k3d-kgerr-lab-server-0
Warning FailedMount 27s (x9 over 2m35s) kubelet MountVolume.SetUp failed for volume "tls" : secret "app-tls" not found
# after creating the Secret, with no other change
$ kubectl get pod stuck-demo -n lab
NAME READY STATUS RESTARTS AGE
stuck-demo 1/1 Running 0 6m13sWhat it means
ContainerCreating means the pod was scheduled and the kubelet is preparing it. It sets up the pod sandbox and network, mounts volumes, pulls images and then creates containers. If any step before the container start is stuck, this status stays.
Volumes are mounted before the image is pulled. In our lab the pod with a missing Secret volume never showed a Pulling event until the Secret existed. Once it did, the pod started on its own.
A missing Secret or ConfigMap used as a volume gives this status. The same object missing from env gives CreateContainerConfigError instead.
Common causes
Secret or ConfigMap volume is missing
The pod mounts a Secret or ConfigMap that does not exist in its namespace.
How to tell: FailedMount event: MountVolume.SetUp failed for volume "<name>" : secret "<name>" not found.
Persistent volume cannot attach or mount
A ReadWriteOnce volume is still attached to another node, the CSI driver is failing or the disk is in another zone.
How to tell: FailedAttachVolume or FailedMount events, often with Multi-Attach error for volume.
Network plugin fails to set up the pod
The CNI plugin is not running on the node, is misconfigured or has run out of pod IPs.
How to tell: FailedCreatePodSandBox event with failed to setup network for sandbox or a CNI error.
A large image is still pulling
The image is big or the registry is slow. This is not an error yet, just a slow step.
How to tell: A Pulling event with no Pulled or Failed event after it.
How to diagnose it
kubectl describe pod <pod> -n <namespace>Events at the bottom show the stuck step: FailedMount, FailedAttachVolume, FailedCreatePodSandBox or Pulling.
kubectl get events -n <namespace> --field-selector involvedObject.name=<pod> --sort-by=.lastTimestampGives the same events in time order with repeat counts, which helps on long-stuck pods.
kubectl get pvc -n <namespace>Claims used by the pod must be Bound. For attach errors also run kubectl get volumeattachment and look for the volume on another node.
kubectl get pods -n kube-system -o wide --field-selector spec.nodeName=<node>Check that the CNI and CSI pods on the same node are Running. A crashing CNI pod blocks every new pod on that node.
kubectl get secret <name> -n <namespace>Confirm any Secret or ConfigMap named in the FailedMount event exists in the pod's namespace.
How to fix it
Create the missing Secret or ConfigMap
Apply it in the pod's namespace. The kubelet retries the mount and the pod starts without a redeploy.
Trade-off: If you create it by hand, add it to your manifests too or the next environment breaks the same way.
Mark the volume optional
Set optional: true on the secret or configMap volume if the app can start without it. The volume mounts empty.
volumes:
- name: tls
secret:
secretName: app-tls
optional: trueTrade-off: The app starts without its files. A missing certificate or config may then fail later and in a less obvious way.
Release the volume from the old node
For Multi-Attach errors, make sure the old pod using the ReadWriteOnce volume is gone so the volume can detach.
Trade-off: Force-deleting the old pod while its node is unreachable risks two writers on one disk. Confirm the old node is down first.
Repair the network plugin
Restart or fix the CNI pod on the affected node, or free IPs in the pod CIDR or subnet.
Trade-off: Restarting the CNI can briefly affect networking for running pods on that node.
How to stop it coming back
- Deploy Secrets and ConfigMaps in the same release as the workloads that mount them.
- Use a Recreate strategy or a StatefulSet for workloads with ReadWriteOnce volumes, so two pods do not try to attach at once.
- Alert on FailedCreatePodSandBox events per node. They usually affect every new pod there.
- Keep images small and pre-pull large ones on new nodes.
How KubeGraf investigates it
Specialist agents pull the logs, events, metrics, workloads and recent deploys for the failing workload into one view. How KubeGraf handles Kubernetes incidents.
Frequently asked questions
What does failed to mount volume mean?
The kubelet could not mount one of the pod's volumes, so the containers never start. Common reasons are a missing Secret or ConfigMap, or a ReadWriteOnce volume still attached to another node. The FailedMount or FailedAttachVolume event names the volume.
What does cni plugin not initialized mean?
The network plugin on that node is not ready, so the kubelet cannot set up the pod's network. The CNI pod may not be running there or its config may be missing. Fix or restart the CNI pod on the affected node.
How long can a pod stay in ContainerCreating?
Until the step it is stuck on succeeds. A large image can take a while to pull and that is not an error yet. A missing Secret volume blocks the pod until the Secret exists, then the pod starts on its own.
Last updated . Try KubeGraf Freemium.
Related
- CreateContainerConfigError
- ImagePullBackOff
- Pending (FailedScheduling)
- Stuck in ContainerCreating: find the blocked step
- Kubernetes Root Cause Analysis: A Complete Guide