Watch pod events

Stream events for a specific pod

kubectl get events -n mynamespace --field-selector involvedObject.name=mypod --watch

tool
k8s-debug27 commands
tags
k8s-debugkubectl

More k8s-debug commands

  • kubectl cp mynamespace/mypod:/var/log/app.log ./app.log

    Download a file from a running container

  • kubectl get po -A --sort-by='.status.containerStatuses[0].restartCount' | tail -20

    Rank pods cluster-wide by restart count to spot crash loops fast

  • kubectl get po -A -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{" "}{.status.containerStatuses[*].lastState.terminated.reason}{"\n"}{end}' | grep OOMKilled

    List pods whose last container exit was OOMKilled across all namespaces

  • kubectl get po -A --field-selector=status.phase=Pending -o name | xargs -I{} kubectl describe {} -n <ns> | grep -A3 FailedScheduling

    Extract FailedScheduling reasons for every Pending pod (taints, resources, affinity)

  • kubectl describe node <node> | grep -A12 Conditions; ssh <node> 'journalctl -u kubelet -n 100 --no-pager'

    Read node Conditions then tail kubelet journal to find why node is NotReady

all 27 k8s-debug commands