Lab 08 - Pod troubleshooting
Lab 08 - Pod troubleshooting
InfodiscoveryGoal: diagnose four broken Pods from cluster output alone. Chapter: Troubleshooting routine
For each case: create the mess with the command given, then answer the question before you open the box. The routine is always get -> describe -> logs.
Case 1 - it will not pull
kubectl run broken1 --image=nginx:doesnotexist
kubectl get pod broken1
Question. What state is it in, and where exactly does the cluster tell you why?
kubectl delete pod broken1
Case 2 - it keeps dying
kubectl run broken2 --image=busybox --restart=Always -- sh -c 'echo starting; exit 1'
sleep 30
kubectl get pod broken2
Question. The RESTARTS counter is climbing. Get the output of the attempt that already failed, not the one running now.
kubectl delete pod broken2
Case 3 - it never gets placed
kubectl run broken3 --image=nginx:1.27 \
--overrides='{"spec":{"containers":[{"name":"broken3","image":"nginx:1.27","resources":{"requests":{"memory":"900Gi"}}}]}}'
kubectl get pod broken3
Question. It stays Pending forever. Which component is complaining, and
what is the exact reason?
Follow-up. Prove it is about requests and not real memory use: how much memory is actually free on worker01?
kubectl delete pod broken3
Case 4 - it runs but answers nothing
kubectl run web --image=nginx:1.27
kubectl expose pod web --port 80 --name web-svc
kubectl label pod web run- # remove the label the Service selects
Question. A client gets a timeout. The Pod is Running and healthy. Find
the break without looking at any logs.
Fix it, then confirm the endpoint comes back.
kubectl delete pod web; kubectl delete svc web-svc
The routine, one more time
kubectl get pod <name> -o wide state, node
kubectl describe pod <name> Events at the bottom - read first
kubectl logs <name> [--previous] [-c ctr] what the app said
kubectl get events --sort-by=.lastTimestamp the wider picture
kubectl exec -it <name> -- sh only when it is running