Pod Lifecycle
A Pod moves through phases such as Pending, Running, Succeeded, and Failed during its life.
Every Pod has a phase that summarizes where it is in its life. You see it in the STATUS column of kubectl get pods.
The phases
- Pending — accepted by the cluster but not yet running (e.g. still pulling the image).
- Running — bound to a node and at least one container is live.
- Succeeded — all containers finished successfully and won't restart.
- Failed — all containers stopped and at least one failed.
- Unknown — the node stopped reporting.
Restart policy
The restartPolicy field controls what happens when a container exits: Always (default), OnFailure, or Never. A crashing container that keeps restarting shows the status CrashLoopBackOff — a very common thing to debug.
Example
# Watch a Pod change phase in real time
kubectl get pods -w
# Inspect events and container states for clues
kubectl describe pod nginx-pod
# Read logs of a crashing container's previous run
kubectl logs nginx-pod --previousWhen to use it
- An SRE watches pod phases in real time during a deployment rollout to confirm pods transition from Pending to Running without going into CrashLoopBackOff.
- A developer adds a preStop hook to gracefully drain in-flight requests before a pod is terminated during a rolling update.
- A platform team investigates an OOMKilled pod by checking its last lifecycle phase and resource usage to right-size memory limits.
More examples
Watch pod phase transitions
Watches pod status in real time to observe the lifecycle phases from Pending through ContainerCreating to Running.
kubectl get pods -w
# NAME READY STATUS RESTARTS
# web 0/1 Pending 0
# web 0/1 ContainerCreating 0
# web 1/1 Running 0Lifecycle hooks in pod spec
Adds postStart and preStop lifecycle hooks: postStart runs immediately after container start, preStop delays SIGTERM by 5 seconds.
spec:
containers:
- name: web
image: nginx:1.25
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "echo started > /tmp/started"]
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 5"]Inspect failed pod reason
Extracts lifecycle failure details from describe output, here showing the pod was killed for exceeding its memory limit.
kubectl describe pod failed-pod | grep -A5 'State:\|Reason:\|Exit Code:'
# State: Terminated
# Reason: OOMKilled
# Exit Code: 137
Discussion