Production-grade triage, debugging, and recovery with kubectl, targeting kubectl / Kubernetes v1.31+ .
Quick Reference
Task Command
Wide pod status kubectl get pods -o wide -n <ns>
Full object state and events kubectl describe pod <pod>
Recent warnings kubectl events -n <ns> --types=Warning
Logs from the crashed container kubectl logs <pod> -c <ctr> --previous
Tail logs across a label kubectl logs -l app=web --prefix --since=15m -f
Shell into a container kubectl exec -it <pod> -c <ctr> -- sh
Ephemeral debug container kubectl debug -it <pod> --image=busybox:1.36 --target=<ctr>
Node shell kubectl debug node/<node> -it --image=busybox:1.36
Resource usage kubectl top pod -n <ns> --sort-by=memory
Rollout progress kubectl rollout status deploy/<name> --timeout=5m
Roll back kubectl rollout undo deploy/<name>
Local tunnel kubectl port-forward svc/<svc> 8080:80
RBAC check kubectl auth can-i <verb> <resource> --as=<user>
Preview changes kubectl diff -f <file>.yaml
Wait for readiness kubectl wait…