debugkubernetesMajorpending
Debug: Kubernetes pod stuck in CrashLoopBackOff
Viewed 0 times
CrashLoopBackOffpodrestartcrashlogshealth-check
Error Messages
Problem
Kubernetes pod keeps restarting with CrashLoopBackOff status. The backoff delay increases each restart.
Solution
Diagnosis steps:
kubectl describe pod <pod-name>
# Look at Events section and Last State
kubectl logs <pod-name> --previous # logs from crashed container
kubectl logs <pod-name> -c <container-name> # specific container
a) Application crash: Fix the app bug (check exit code in describe output)
b) Missing config/secret:
kubectl get configmaps
kubectl get secrets
c) Failed health check: Adjust livenessProbe timing
livenessProbe:
initialDelaySeconds: 30 # Give app time to start
periodSeconds: 10
failureThreshold: 3
d) Resource limits too low:
resources:
limits:
memory: 512Mi # Increase if OOMKilled
e) Permission issues: Check serviceAccountName and RBAC
kubectl run debug --image=<image> --command -- sleep infinity
kubectl exec -it debug -- /bin/sh
kubectl scale deployment <name> --replicas=0
- Check pod events and status:
kubectl describe pod <pod-name>
# Look at Events section and Last State
- Check container logs:
kubectl logs <pod-name> --previous # logs from crashed container
kubectl logs <pod-name> -c <container-name> # specific container
- Common causes and fixes:
a) Application crash: Fix the app bug (check exit code in describe output)
b) Missing config/secret:
kubectl get configmaps
kubectl get secrets
c) Failed health check: Adjust livenessProbe timing
livenessProbe:
initialDelaySeconds: 30 # Give app time to start
periodSeconds: 10
failureThreshold: 3
d) Resource limits too low:
resources:
limits:
memory: 512Mi # Increase if OOMKilled
e) Permission issues: Check serviceAccountName and RBAC
- Debug interactively (override entrypoint):
kubectl run debug --image=<image> --command -- sleep infinity
kubectl exec -it debug -- /bin/sh
- Temporary fix to stop crash loop:
kubectl scale deployment <name> --replicas=0
Revisions (0)
No revisions yet.