Prompt
My Kubernetes pods keep restarting how do I troubleshoot this
Latest observation
Here’s a practical way to troubleshoot Kubernetes pod restarts.
1) Check what is restarting and how often
kubectl get pods -A
kubectl get pods -n <namespace> -o wide
kubectl get pod <pod-name> -n <namespace>
Look at:
- RESTARTS count
- STATUS:
CrashLoopBackOff,Error,OOMKilled,Completed, etc. - AGE
2) Describe the pod
This is usually the fastest way to see why it’s restarting:
kubectl describe pod <pod-name> -n <namespace>
Pay attention to:
- Events at the bottom
- Last State
- Reason fields like:
OOMKilledErrorContainerCannotRunCrashLoopBackOffLiveness probe failedReadiness probe failed
3) Check the logs
If the container crashes, inspect current and previous logs:
kubectl logs <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace> --previous
If there are multiple containers:
kubectl logs <pod-name> -n <namespace> -c <container-name>
kubectl logs <pod-name> -n <namespace> -c <container-name> --previous
Common log clues:
- app startup failure
- missing config/env vars
- connection failures to DB/API
- syntax/runtime exceptions
- permission errors
4) Check if it’s OOMKilled
If the pod is being killed for memory:
kubectl describe pod <pod-name> -n <namespace>
Look for:
Reason: OOMKilled- exit code
137
Then inspect resources:
kubectl get pod <pod-name> -n <namespace> -o yaml
Check:
- memory requests/limits
- whether the app needs more memory
- node memory pressure
You may need to raise memory limits or fix a memory leak.
5) Check probes
Bad liveness/startup probes can cause restart loops.
Inspect:
kubectl get pod <pod-name> -n <namespace> -o yaml
Look for:
livenessProbereadinessProbestartupProbe
Common issues:
- probe path/port wrong
- app starts too slowly
- timeout too short
- probe depends on external service
If the app needs more startup time, add a startupProbe or relax the liveness probe.
6) Check deployment/config changes
If restarts started after a deploy or config change, compare:
kubectl rollout history deployment/<deployment-name> -n <namespace>
kubectl describe deployment <deployment-name> -n <namespace>
Also check:
- ConfigMaps
- Secrets
- image tag changes
- env vars
- mounted volumes
7) Check node health
Sometimes the pod is fine but the node is unhealthy.
kubectl get nodes
kubectl describe node <node-name>
Look for:
- memory/disk pressure
- node reboots
- network issues
- kubelet problems
8) Check if the pod is being evicted or terminated externally
Look for:
EvictedNodeNotReadyPreemptedTerminatedKilled
You can also check events:
kubectl get events -A --sort-by=.lastTimestamp
9) If it’s a Job or Completed pod
If the pod is from a Job, it may exit successfully and restart depending on controller settings.
Check:
kubectl describe pod <pod-name> -n <namespace>
kubectl describe job <job-name> -n <namespace>
10) Quick common causes
Most restart loops come from:
- app crashes on startup
- bad env vars or missing secrets
- failing liveness probe
- OOMKilled due to memory limits
- dependency unavailable (DB, Redis, API)
- bad image / entrypoint / command
- permission or volume mount issues
Fastest triage command sequence
Run these in order:
kubectl get pods -n <namespace>
kubectl describe pod <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace> --previous
kubectl get events -n <namespace> --sort-by=.lastTimestamp
If you want, paste the output of:
kubectl describe pod <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace> --previous
and I can help you interpret it.
Brands