Pod Status Analyzer
Beginner5 min
Quickly diagnose common pod failure states including CrashLoopBackOff, ImagePullBackOff, Pending, and OOMKilled.
Prerequisites
- -kubectl configured
Steps
1
Get pod status with restart count
View the current status and restart count for pods.
$ kubectl get pods -o custom-columns='NAME:.metadata.name,STATUS:.status.phase,RESTARTS:.status.containerStatuses[0].restartCount,REASON:.status.containerStatuses[0].state.waiting.reason'
2
Check why a pod is Pending
View scheduling events to understand why a pod cannot be placed on a node.
$ kubectl describe pod <pod-name> | grep -A10 'Events:'
Common causes: insufficient resources, node affinity/taint issues, or PVC binding failures.
3
Diagnose CrashLoopBackOff
View logs from the crashed container to understand the failure.
$ kubectl logs <pod-name> --previous
The --previous flag shows logs from the last crashed instance, which is where the error usually is.
4
Check for OOMKilled containers
Find containers that were killed due to exceeding their memory limit.
$ kubectl get pods -o json | jq -r '.items[] | select(.status.containerStatuses[]?.lastState.terminated.reason=="OOMKilled") | .metadata.name'
OOMKilled means the container exceeded its memory limit. Increase the limit or optimize memory usage.
Full Script
FAQ
Discussion
Loading comments...