CKAD — Debugging Pods
5-Step Debugging Workflow
When a Pod isn’t working, follow these steps in order:
Step 1: Check Pod Status
kubectl get pod my-pod
kubectl get pod my-pod -o wide
# Common problem statuses:
# CrashLoopBackOff — Container keeps crashing
# ImagePullBackOff — Cannot pull the container image
# Pending — Cannot be scheduled
# Error — Container exited with error
# OOMKilled — Container ran out of memory
Step 2: Describe the Pod
kubectl describe pod my-pod
Focus on these sections:
- Status — Current Pod phase
- Conditions — Ready, Initialized, ContainersReady
- Events — Recent events (scheduling, pulling, starting, probe failures)
- State / Last State — Current and previous container state with exit codes
Step 3: Check Events
# All events in the namespace (sorted by time)
kubectl get events --sort-by=.lastTimestamp
# Events for a specific Pod
kubectl get events --field-selector involvedObject.name=my-pod
Step 4: Execute Commands Inside the Container
# Run a command
kubectl exec my-pod -- ls /app
kubectl exec my-pod -- cat /etc/config/app.yaml
kubectl exec my-pod -- env
# Interactive shell
kubectl exec -it my-pod -- /bin/sh
kubectl exec -it my-pod -- /bin/bash
# Specific container in multi-container Pod
kubectl exec -it my-pod -c sidecar -- /bin/sh
Step 5: Check Resource Usage
# Pod CPU and memory usage (requires metrics-server)
kubectl top pod my-pod
kubectl top pods -l app=web
# Node resource usage
kubectl top nodes
Debugging cheat sheet: get → describe → events → logs --previous → exec. This order covers 90% of debugging scenarios on the exam.
Next: Common Pod Problems