--- name: debug-eks description: > Use when a pod is crashing, not starting, or behaving unexpectedly in Kubernetes/EKS. Also triggers for OOMKilled, ImagePullBackOff, CrashLoopBackOff, Pending pods, or any kubectl debugging questions. license: MIT --- # EKS debugging — triage order Always follow this sequence. Don't jump to solutions before triage. ## Step 1 — Pod status ```bash kubectl get pods -n -l app= kubectl describe pod -n # ↑ Read the Events: section at the bottom — this is where the error lives. ``` ## Step 2 — Logs ```bash kubectl logs -n --tail=200 kubectl logs -n --previous --tail=200 # if crashed kubectl logs -l app= -n --tail=100 # all pods ``` ## Step 3 — Events ```bash kubectl get events -n --sort-by='.lastTimestamp' | tail -20 ``` ## Common failures ### CrashLoopBackOff App crashes on startup. Check previous logs first. Common causes: missing env var, wrong secret name, DB connection refused. ```bash kubectl exec -it -n -- env | grep -i db # check env vars kubectl get secret -n # verify secret exists ``` ### OOMKilled Container exceeded memory limit. Increase `resources.limits.memory` in Helm values. ```bash kubectl describe pod -n | grep -A5 "OOMKilled\|Limits" ``` ### ImagePullBackOff Kubelet cannot pull the image. Check: image tag exists in Artifactory, `imagePullSecrets` configured, IRSA has ECR permissions. ### Pending No node available. Check resource requests vs node capacity, taints/tolerations. ```bash kubectl describe pod -n | grep -A10 "Events:" kubectl top nodes ``` ## Useful one-liners ```bash kubectl get pods -A --field-selector=status.phase!=Running # all non-running pods kubectl port-forward svc/ 8080:8080 -n # local debugging kubectl exec -it -n -- /bin/sh # shell into pod kubectl top pods -n --sort-by=memory # resource usage ```