Sub topic 8
Diagnosing ImagePullBackOff, CrashLoopBackOff, FailedScheduling, and OOMKilled
This chapter assumes you can run kubectl get and kubectl describe, and that you know the difference between Pod phase, container state, and events from earlier chapters. Four failure patterns cover a large share of broken Pods. Each one shows up in a different place, so the skill is knowing where to look first.
Where each failure appears
| Symptom | Where it shows | Typical cause |
|---|---|---|
| ImagePullBackOff, ErrImagePull | Container `waiting` reason, Events | Wrong image name or tag, missing registry credentials |
| CrashLoopBackOff | Container `waiting` reason, `lastState.terminated` | The process exits with an error |
| FailedScheduling | Pod phase `Pending`, Warning event from the scheduler | No node fits the Pod's requests or constraints |
| OOMKilled | `lastState.terminated.reason` | The container exceeded its memory limit |
ImagePullBackOff
The kubelet (the node agent) pulls the image. If the pull fails, the container waits with ErrImagePull. After repeated failures the kubelet backs off between retries and the reason becomes ImagePullBackOff.
kubectl get pod web-0
kubectl describe pod web-0The Events section holds the real reason. Look for Failed events with messages such as manifest unknown (the tag does not exist), pull access denied (credentials or a private repository), or a DNS or network timeout. Check the image string in spec.containers[].image for typos, and check that imagePullSecrets exists for private registries.
CrashLoopBackOff
CrashLoopBackOff is not the error itself. It means the container started, exited, and the kubelet is waiting before restarting it, with a delay that grows up to five minutes. The cause is in the last termination and the logs of the previous instance.
kubectl get pod web-0 -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'
kubectl logs web-0 --previousAn exitCode of 1 usually means the application reported an error. Exit code 137 means the process received SIGKILL, often from the out-of-memory killer. A liveness probe that keeps failing also causes restarts, so check the probe configuration if the logs look healthy.
FailedScheduling
A Pod stuck in Pending with no container statuses has not reached a node. The scheduler records why.
kubectl get events --field-selector involvedObject.name=web-0A typical message is 0/3 nodes are available: 3 Insufficient memory. The message lists each reason and how many nodes it excluded. Common reasons are:
- Insufficient CPU or memory compared with the Pod's
requests. - Node taints that the Pod does not tolerate.
- A
nodeSelectoror affinity rule that matches no node. - An unbound PersistentVolumeClaim.
Compare the Pod's requests with node capacity, and fix the request, the constraint, or the cluster size.
OOMKilled
When a container exceeds its memory limit, the kernel kills it. Kubernetes records the reason in the terminated state. The Pod then restarts, and you often see CrashLoopBackOff afterward.
lastState:
terminated:
reason: OOMKilled
exitCode: 137kubectl get pod web-0 -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'If the reason is OOMKilled, either the limit is too low for normal use or the application leaks memory. Raise resources.limits.memory only after you confirm the workload needs it.
Common mistakes
- Reading only the Pod phase. A
RunningPod can be inCrashLoopBackOff. - Treating
CrashLoopBackOffas the root cause instead of readinglastState. - Skipping the Events section. Pull and scheduling failures are explained there.
- Looking too late. Events expire, so capture them soon after the problem starts.
Exercise
A Pod shows STATUS CrashLoopBackOff and RESTARTS 6. The logs from kubectl logs web-0 are empty. What two things do you check next, and what would exit code 137 with reason OOMKilled tell you?
Show answer
Run kubectl logs web-0 --previous to read the output of the failed instance, and read status.containerStatuses[0].lastState.terminated for the reason and exit code. Exit code 137 with reason OOMKilled means the container exceeded its memory limit and was killed, so you compare its memory usage with resources.limits.memory.