Watch pod events k8s-debug
Stream events for a specific pod
kubectl get events -n mynamespace --field-selector involvedObject.name=mypod --watch
more k8s-debug
all 27 commands →
Copy file from pod
kubectl cp mynamespace/mypod:/var/log/app.log ./app.log
Top pods by restart count
kubectl get po -A --sort-by='.status.containerStatuses[0].restartCount' | tail -20
Detect OOMKilled containers
kubectl get po -A -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{" "}{.status.containerStatuses[*].lastState.terminated.reason}{"\n"}{end}' | grep OOMKilled
Pending pods scheduling reason
kubectl get po -A --field-selector=status.phase=Pending -o name | xargs -I{} kubectl describe {} -n <ns> | grep -A3 FailedScheduling
Node NotReady triage
kubectl describe node <node> | grep -A12 Conditions; ssh <node> 'journalctl -u kubelet -n 100 --no-pager'