Find pods by resource usage k8s-debug
Top 20 pods sorted by memory consumption
kubectl top pods -A --sort-by=memory | head -20
more k8s-debug
all 27 commands →
Watch pod events
kubectl get events -n mynamespace --field-selector involvedObject.name=mypod --watch
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