All posts

/4 min read/By Mohamed Benlmaoujoud

Something is broken. Start here.

A calm, six-step method for debugging any Kubernetes failure: recognize, check, read, narrow, fix, verify.

The impediment to action advances action. What stands in the way becomes the way.
Marcus Aurelius, Meditations 5.20

A broken cluster feels urgent, and urgency is where most debugging goes wrong. People change three things at once, restart what they do not understand, and lose the evidence. The fix is not speed. It is order.

1. Recognize the symptom

Name what you see before you guess why. A pod that restarts is not the same problem as a pod that never starts, and neither is a service that answers nothing.

kubectl get deploy,pods,svc -A

2. Check what is in your control

The Stoics separated what is up to us from what is not. In a cluster, the namespace, the manifest and the selector are up to you. Start there, not with the scheduler.

3. Read before you change

Events and logs already know the answer most of the time. Read them slowly. The last event is usually the honest one.

kubectl describe pod <name> -n <ns>
kubectl get events -n <ns> --sort-by=.lastTimestamp
kubectl logs <pod> -n <ns> --previous

4. Narrow it to one cause

Ask one question at a time: is it the image, the config, the resources, the network? Each answer removes half the possibilities.

5. Fix one thing

Change the smallest thing that addresses the cause you found. If it does not work, undo it before you try the next idea, so you always know what the cluster is running.

6. Verify, then stop

A fix is not a fix until the cluster says so. Watch the pod reach Running and the service answer. Then stop: the urge to keep tweaking a working system is how new incidents begin.

kubectl rollout status deploy/<name> -n <ns>
kubectl get pods -n <ns> -w

That is the whole method. Every problem on leetops is a place to practice it on a real, broken cluster, until the order becomes a reflex.