Prompt
Why are my pods restarting in Kubernetes?
Latest observation
Pods in Kubernetes restart for a few common reasons. The exact cause depends on whether the container is restarting inside the same pod, or the pod itself is being recreated by a controller like a Deployment.
Common reasons
1. App crashes or exits
If the main process in the container exits with a non-zero code, Kubernetes restarts it.
Check:
kubectl describe pod <pod-name>
kubectl logs <pod-name> --previous
Look for:
CrashLoopBackOff- exit codes like
1,137,143
2. Liveness probe failures
If your liveness probe fails, Kubernetes assumes the container is unhealthy and restarts it.
Check in describe pod:
Liveness probe failed- probe timeout / connection refused / HTTP errors
3. Resource limits being hit
If the container uses too much memory, it may be OOM-killed.
Signs:
- exit code
137 OOMKilledin pod status
Check:
kubectl describe pod <pod-name>
Look for:
Last State: TerminatedReason: OOMKilled
4. Readiness probe issues
Readiness probe failures do not usually restart the pod, but they can make it look “broken” because traffic stops going to it.
5. Node problems
If the node is under pressure, drained, or crashes, pods may be evicted or rescheduled elsewhere.
Check:
kubectl get pod -o wide
kubectl describe node <node-name>
Look for:
EvictedNodeNotReadyMemoryPressure,DiskPressure,PIDPressure
6. Deployment rolling updates or scaling
The pod may not be restarting; it may be getting replaced during:
- rollout
- image update
- autoscaling
- manual delete/recreate
Check:
kubectl rollout status deployment/<name>
kubectl get events --sort-by=.metadata.creationTimestamp
7. Failing startup probe
If a startup probe fails, Kubernetes restarts the container before it can come up fully.
Best troubleshooting steps
-
Describe the pod
kubectl describe pod <pod-name> -
Check current and previous logs
kubectl logs <pod-name> kubectl logs <pod-name> --previous -
Inspect restart count
kubectl get pod <pod-name> -
Check events
kubectl get events --sort-by=.metadata.creationTimestamp -
Check probes, resources, and node health
- liveness/startup/readiness probe config
- memory/cpu limits
- node conditions
Quick interpretation guide
CrashLoopBackOff→ app is crashing or probe is failingOOMKilled→ memory limit exceededError/ exit code1→ app terminated unexpectedlyEvicted→ node pressure or scheduling issueCompleted→ job-like workload finished normally
If you want, paste the output of:
kubectl describe pod <pod-name>
kubectl logs <pod-name> --previous
and I can help pinpoint the exact reason.