Kubernetes
devopskubernetesGuideIntermediate
Kubernetes Troubleshooting & Diagnostics Guide
A systematic troubleshooting methodology and decision tree for debugging CrashLoopBackOff, ImagePullBackOff, Pending pods, and Service routing failures.
Verified: 2026-10-01
Tested on:kubernetes 1.31
Platforms:
all
#kubernetes#troubleshooting#debugging#crashloopbackoff#imagepullbackoff
Kubernetes Troubleshooting & Diagnostics Guide
When things go wrong in a Kubernetes cluster, follow a systematic diagnostic triage process from the cluster layer down to the container logs.
1. The 4-Step Diagnostic Workflow
[ Step 1: Check Pod Status ] ──► kubectl get pods -o wide
│
▼
[ Step 2: Read Cluster Events ] ──► kubectl describe pod <pod-name>
│
▼
[ Step 3: Check Application Logs ] ──► kubectl logs <pod-name> (--previous)
│
▼
[ Step 4: Inspect Networking ] ──► kubectl get endpoints <service-name>2. Troubleshooting Decision Tree
Scenario A: Pod is Stuck in Pending
- Diagnosis: Pod cannot be scheduled onto any worker node.
- Action: Run
kubectl describe pod <pod-name>and look at the bottom Events section. - Common Causes:
0/3 nodes are available: insufficient cpu/memory: Cluster nodes do not have enough unallocated allocatable resources to satisfyrequests.PersistentVolumeClaim is not bound: Waiting for storage provisioner or PV.NodeSelector / NodeAffinity mismatch: No nodes match the specified label.
Scenario B: Pod in CrashLoopBackOff
- Diagnosis: Container starts, exits with an error code, and kubelet restarts it with increasing backoff delays.
- Action:
# Check logs of the previous crashed instance: kubectl logs <pod-name> --previous - Common Causes:
- Application threw an uncaught error at startup (e.g. missing
DATABASE_URLenvironment variable). - Database connection refused.
- Liveness probe is failing or initial delay is too short.
- Application threw an uncaught error at startup (e.g. missing
Scenario C: Pod in ImagePullBackOff or ErrImagePull
- Diagnosis: Container runtime cannot pull the container image from the registry.
- Common Causes:
- Typo in image repository name or version tag (e.g.
node:99-alpine). - Private registry credentials missing: You need to specify
imagePullSecrets: [{name: regcred}].
- Typo in image repository name or version tag (e.g.
Scenario D: Pod is OOMKilled (Exit Code 137)
- Diagnosis: Container consumed more RAM than allowed by
resources.limits.memory. - Action: Check
kubectl describe pod <pod-name>:State: Terminated Reason: OOMKilled Exit Code: 137 - Fix: Increase memory limits in the PodSpec or profile memory leaks in application code.
Scenario E: Service Returns 503 or Requests Hang
- Diagnosis: Traffic reaching the Service is not routing to backend Pods.
- Action: Check if the Service has active registered endpoints:
Ifkubectl get endpoints <service-name>ENDPOINTS: <none>:- Verify
spec.selectorin Service YAML matchesspec.template.metadata.labelsin Deployment YAML. - Verify Pods are passing their
readinessProbe.
- Verify