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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

kubectl events [-n NAMESPACE] [--for TYPE/NAME] [--types Warning]

Parameters

ParameterDescription
--for TYPE/NAME Events about one object.
--types Warning Only warnings.
-w Watch.

Examples

Warnings for one pod
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.

A healthy pod's lifecycle events
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.

Was this page helpful?