Pod Startup and Scheduling Errors — ImagePullBackOff, CrashLoopBackOff, Pending, Evicted

The failures between an accepted manifest and a running process: image pulls, crash loops, missing config, unschedulable pods, init containers, pod IP exhaustion and node-pressure eviction, with the commands and the cloud-specific causes.

Overview

These errors happen after the API server has accepted your manifest but before your application does useful work. The Pod object exists, so kubectl get pods lists it, but it is stuck somewhere on the way to Running, or it got there and was thrown off the node. Each status name is a place on that path, and the Events at the bottom of kubectl describe pod say exactly what went wrong there.

Work through it in order, starting with one question. Has the pod been given a node? If not, the scheduler is the only component involved, and its one-line summary (0/N nodes are available: ...) counts every node and the reason each was rejected. If it has a node, the kubelet on that node owns everything that follows: admission, the network sandbox, the image pull, init containers, building the container config, and starting the process. Reading the node assignment first cuts the problem in half.

The idea to keep: a status like CrashLoopBackOff or ImagePullBackOff is a retry timer, not a diagnosis. The cause is in the Events, the previous container's logs, or the exit code. Strong engineers go straight to those three places and never restart pods hoping the problem goes away.

Where a pod can stop on its way to Running

The path has eleven stops. Every stop where a pod can fail has its own status names, a usual cause and one command that shows the evidence. The first three stops belong to the scheduler; from the bind at stop 4 on, everything belongs to the kubelet on one node.

  • Scheduling gates. The API server has accepted the Pod, but a scheduling gate was never removed, so the pod shows SchedulingGated. Read the gates with kubectl get pod -n prod -o jsonpath='{.spec.schedulingGates}'.
  • The scheduler's filter and score. The pod stays Pending. With Insufficient cpu, its requests do not fit any node's free allocatable, so start with kubectl events -n prod --for pod/. With taint, affinity or spread messages, placement rules exclude every node, so start with kubectl describe pod -n prod.
  • Preemption. When nothing fits, the scheduler may remove lower-priority pods to make room for a higher-priority one. The victims vanish with the event Preempted; list them with kubectl get events -n prod --field-selector reason=Preempted.
  • Bound to a node. The scheduler's part ends here, and the kubelet on that node takes over.
  • Kubelet admission. The kubelet can still refuse the pod after it was bound, with OutOfcpu, OutOfpods or UnexpectedAdmissionError. Read why with kubectl get pod -n prod -o jsonpath='{.status.message}'.
  • The sandbox and its CNI IP. The pod sits in ContainerCreating with FailedCreatePodSandBox when the CNI plugin cannot give it an IP. Run kubectl describe pod -n prod, then check the subnet's free IPs.
  • The image pull. ErrImagePull and ImagePullBackOff come from a wrong tag, missing pull credentials or no route to the registry, and kubectl describe pod -n prod shows the Failed to pull line. InvalidImageName means the image string does not parse (an uppercase repository, an empty tag, an unrendered template); print it with kubectl get pod -n prod -o jsonpath='{..image}'.
  • Init containers. Init:CrashLoopBackOff or Init:0/2 means an init container fails or never exits. Read its logs with kubectl logs -n prod -c .
  • Building the container config. CreateContainerConfigError means a referenced ConfigMap, Secret or key does not exist, and kubectl describe pod -n prod names it.
  • The process runs. CrashLoopBackOff means the process exits at startup or a liveness probe kills it. Start with kubectl logs -n prod --previous.
  • Node pressure. Evicted, with phase Failed, means the kubelet reclaimed memory or disk under node pressure. Read the Conditions in kubectl describe node .

Key concepts

  • Back-off (CrashLoopBackOff, ImagePullBackOff)
  • Requests versus usage
  • Allocatable
  • Taints, tolerations and affinity
  • Topology spread constraints
  • Native sidecar container
  • Pod sandbox
  • Node-pressure eviction
  • Preemption
  • Scheduling gates

Interview questions

  • After a release, the new ReplicaSet shows ImagePullBackOff on about half the pods while the rest run fine. Walk me through it.
  • A pod is in CrashLoopBackOff and kubectl logs --previous prints nothing. How do you find the cause?
  • Pods are Pending with 0/12 nodes are available: 12 Insufficient cpu, and the cluster autoscaler is not adding nodes. What do you check?
  • One Availability Zone had an outage. Afterwards, some StatefulSet pods stay Pending even though the other zones have plenty of room. Why?
  • During a large scale-up on EKS, new pods sit in ContainerCreating with FailedCreatePodSandBox. How would the same problem look on AKS and GKE?
  • Several nodes report DiskPressure and pods are being evicted. The team says BestEffort pods always go first, so they are not worried about their Guaranteed database. Are they right?
  • A pod is stuck in Init:0/2. The first init container waits for Postgres and the app also needs the Cloud SQL Auth Proxy. What is wrong and how do you redesign it?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio