DevOps & Kubernetes (50 Qs)•Part 3: Production K8s Scaling, Reliability & SRE (26 - 35)
How do you systematically troubleshoot CrashLoopBackOff, ImagePullBackOff, and Pending Pods?
Step-by-Step Production Troubleshooting Guide
When a Pod fails to reach Running state, execute this diagnostic flow before making code or configuration changes.
scss
[ Pod Status Abnormal ]
|
+---> [ Pending ] --------> 1. kubectl describe pod (Check Scheduler Events, CPU/Mem, Affinity)
|
+---> [ ImagePullBackOff ] -> 2. Check Image Name, Tag, and imagePullSecrets
|
+---> [ CrashLoopBackOff ] -> 3. kubectl logs --previous (Inspect crash stack trace)
Diagnostic Checklist Matrix
| Error State | Root Cause | Immediate Diagnostic Command | Fix Action |
|---|---|---|---|
Pending | Node resources exhausted, node selector mismatch, or unfulfilled PVC. | `kubectl describe pod <pod> | grep -A 10 Events:` |
ImagePullBackOff | Tag typo, non-existent repository, or registry authentication failure. | kubectl describe pod <pod> | Verify image tag; check imagePullSecrets for private registries (ECR/DockerHub). |
CrashLoopBackOff | Container starts, encounters fatal error (exit code 1 or 137), and exits. | kubectl logs <pod> --previous | Inspect application logs just before crash; verify DB connection strings and config files. |
CreateContainerConfigError | Missing ConfigMap or Secret referenced in Pod spec. | kubectl describe pod <pod> | Create the missing ConfigMap/Secret or fix key names. |
Pro-Tip: Ephemeral Debug Containers
For distroless or hardened containers without a shell, attach an interactive debug container directly into the pod’s network and process namespace:
bash
kubectl debug -it <crashing-pod> --image=nicolaka/netshoot --target=app-container