Computer Notes/Kubernetes/Kubernetes Troubleshooting Cheat Sheet
Kubernetes Troubleshooting Cheat Sheet
A rapid triage reference for debugging Kubernetes clusters, pods, networking, and AWS EKS IAM permissions. Follow the standard incident cadence: mitigate first to restore service, then deep-dive into root cause.
1. Context & First-Look Triage
Run these commands first to orient yourself and spot broken workloads across the cluster
Verify which cluster and namespace you are targeting
kubectl config current-context kubectl config set-context --current --namespace=<ns>
Fast scan: show every pod that is NOT Running
kubectl get pods -A --field-selector=status.phase!=Running
Detailed pod view (READY, STATUS, RESTARTS, IP, NODE)
kubectl get pods -n <ns> -o wide
Check node health (NotReady, MemoryPressure, DiskPressure)
kubectl get nodes -o wide kubectl top nodes kubectl top pods -n <ns> --sort-by=memory
2. Inspecting Failures (Events & Logs)
Follow the standard debugging flow: get → describe → logs → events.
Read the bottom "Events" table (scheduling, image pull, probes, OOMKilled)
kubectl describe pod <pod> -n <ns>
View logs from the PREVIOUS crashed container (essential for CrashLoopBackOff)
kubectl logs <pod> -n <ns> --previous
Stream live logs or grab the last 100 lines across all replicas of an app
kubectl logs -f <pod> -n <ns> --tail=100 kubectl logs -l app=<label> -n <ns> --tail=100
Multi-container pod (specify container name)
kubectl logs <pod> -c <container> -n <ns>
Cluster-wide warning events sorted chronologically
kubectl get events -n <ns> --field-selector type=Warning --sort-by=.lastTimestamp
3. Immediate Mitigation & Rollbacks
Unblock production SLAs and isolate faulty nodes before digging into root cause.
Check deployment rollout history and undo a bad release
kubectl rollout status deployment/<name> -n <ns> kubectl rollout undo deployment/<name> -n <ns>
Scale healthy replicas up (or scale a broken worker down to 0)
kubectl scale deployment/<name> --replicas=<count> -n <ns>
Isolate a bad node (stop new pods from scheduling on it)
kubectl cordon <node> kubectl drain <node> --ignore-daemonsets --delete-emptydir-data
4. Live Shell, Networking & DNS Checks
Use these when a pod or worker is timing out or failing to reach internal services or external APIs.
Shell into a running container
kubectl exec -it <pod> -n <ns> -- /bin/sh
Attach an ephemeral debug container (works on distroless images with no shell)
kubectl debug -it <pod> -n <ns> --image=busybox --target=<container>
Spin up a temporary network debug pod (dig, nslookup, curl, tcpdump)
kubectl run netdebug --rm -it --image=nicolaka/netshoot -n <ns> -- /bin/bash
Verify Service-to-Pod selector matching (if <none>, labels don't match)
kubectl get svc,endpoints -n <ns>
Test CoreDNS and external egress from inside a pod
nslookup kubernetes.default nslookup s3.amazonaws.com
Forward a local port to test a pod/service directly
kubectl port-forward svc/<svc> 8080:80 -n <ns>
5. Scaling, Configs & AWS EKS IAM
Commands for inspecting autoscaling, configuration objects, RBAC, and the Kubernetes-to-AWS IAM boundary (IRSA / EKS Pod Identity).
Check Horizontal Pod Autoscaler (if <unknown>, pod is missing resources.requests)
kubectl get hpa -n <ns> kubectl describe hpa <hpa-name> -n <ns>
Verify ConfigMaps, Secrets, and Storage
kubectl get cm,secret,pvc -n <ns>
Check which ServiceAccount a pod is using (for IRSA / EKS Pod Identity)
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.serviceAccountName}'
Verify the IRSA IAM role annotation on the ServiceAccount
kubectl describe sa <sa-name> -n <ns>
Check Kubernetes RBAC permissions for a ServiceAccount
kubectl auth can-i --list --as=system:serviceaccount:<ns>:<sa-name> -n <ns>
6. Quick Status-to-Command Lookup
| Status You See | First Command to Run | What to Look For |
|---|---|---|
| Pending | kubectl describe pod <pod> |
FailedScheduling, insufficient CPU/RAM, taint mismatch, or unbound PVC.
|
| CrashLoopBackOff | kubectl logs <pod> --previous |
App startup error, missing env var/Secret, or aggressive livenessProbe.
|
| OOMKilled (Exit 137) | kubectl describe pod <pod> |
Last State: Terminated (Reason: OOMKilled). Raise memory limits or reduce worker batch size.
|
| ImagePullBackOff | kubectl describe pod <pod> |
Bad image tag, missing imagePullSecrets, or EKS node missing ECR read permissions / NAT egress.
|
| AccessDenied (AWS) | kubectl describe sa <sa> |
Missing eks.amazonaws.com/role-arn annotation, OIDC trust policy mismatch, or KMS key policy block.
|