kubectl 1.37 reference · Debugging
kubectl events Command (kubectl)
List recent cluster events (scheduling, image pulls, probe failures, kills) for a namespace or one resource, sorted by time.
kubectl 1.37
Syntax
kubectl events [-n NAMESPACE] [--for TYPE/NAME] [--types Warning]
Parameters
| Parameter | Description |
|---|---|
--for TYPE/NAME |
Events about one object. |
--types Warning |
Only warnings. |
-w |
Watch. |
Examples
kubectl create namespace rc-ref-ev > /dev/null
trap 'kubectl delete namespace rc-ref-ev --wait=false > /dev/null' EXIT
kubectl -n rc-ref-ev run broken --image=busybox:does-not-exist > /dev/null
kubectl -n rc-ref-ev wait --for=jsonpath='{.status.containerStatuses[0].state.waiting.reason}'=ImagePullBackOff pod/broken --timeout=120s > /dev/null
kubectl -n rc-ref-ev events --for pod/broken --types Warning -o jsonpath='{range .items[*]}{.reason}{"\n"}{end}' | sort -u
Output
Failed
Run this on your computer — see “Get Started” for setup.
kubectl create namespace rc-ref-ev2 > /dev/null
trap 'kubectl delete namespace rc-ref-ev2 --wait=false > /dev/null' EXIT
kubectl -n rc-ref-ev2 run ok --image=busybox:1.37 -- sleep 3600 > /dev/null
kubectl -n rc-ref-ev2 wait --for=condition=Ready pod/ok --timeout=120s > /dev/null
kubectl -n rc-ref-ev2 events --for pod/ok -o jsonpath='{range .items[*]}{.reason}{"\n"}{end}' | sort -u
Output
Created Pulled Scheduled Started
Run this on your computer — see “Get Started” for setup.
Related
kubectl describe· Show a detailed, human-readable view of a resource, including related events, the first place to look when debugging.kubectl logs· Print a container's logs from a pod, deployment or job; follow them, limit lines, or read the previous crashed container.- Troubleshooting Pods · tutorial