LinuxCommandLibrary

kubectl-events

Stream Kubernetes events

TLDR

Show events in the default namespace

$ kubectl events
copy

Show events in all namespaces
$ kubectl events [[-A|--all-namespaces]]
copy

Watch events in a specific namespace
$ kubectl events [[-w|--watch]] [[-n|--namespace]] [namespace]
copy

Show events for a pod in a specific namespace
$ kubectl events --for [pod]/[pod_name] [[-n|--namespace]] [namespace]
copy

Show events for a resource in a specific namespace
$ kubectl events --for [resource]/[resource_name] [[-n|--namespace]] [namespace]
copy

Show events for type Warning or Normal
$ kubectl events --types Warning,Normal
copy

Output events in YAML format
$ kubectl events [[-o|--output]] yaml
copy

SYNOPSIS

kubectl events [OPTIONS]

PARAMETERS

--all-namespaces, -A
    List events from all namespaces (default: false)

--chunk-size int
    Chunk size for API server requests (default: 500)

--field-selector string
    Filter by fields, e.g., 'reason=FailedScheduling', 'involvedObject.name=my-pod'

--for resource[/name]
    Show events related to specific resource, e.g., 'pod/my-pod' or 'deployment/my-app'

--sort-by string
    Sort output by field name, e.g., 'lastTimestamp'

-n, --namespace string
    Namespace for events (default: current)

DESCRIPTION

The kubectl events command streams and lists watchable events from a Kubernetes cluster, providing real-time insights into cluster activities. Events capture significant occurrences like pod scheduling, container restarts, node failures, resource quotas exceeded, or controller reconciliations.

By default, it tails recent events in the current namespace indefinitely. Key use cases include debugging deployment issues, monitoring scheduler decisions, and troubleshooting node problems. Output columns include LAST SEEN, TYPE (Normal/Warning), REASON, OBJECT, and MESSAGE.

Unlike kubectl get events, which snapshots events at a point in time, kubectl events watches for new ones dynamically. It's efficient for live monitoring but relies on the Event API, which has a default 1-hour TTL, meaning older events may expire.

CAVEATS

Events have ~1h TTL and may not persist; output not perfectly ordered in distributed clusters; requires watch permissions.

EXAMPLES

kubectl events --for pod/nginx # Events for specific pod
kubectl events -A --field-selector reason=NodeNotReady # Node failures cluster-wide

OUTPUT FORMAT

Columns: LAST SEEN | TYPE | REASON | OBJECT | SOURCE | MESSAGE
Supports --output=json/yaml

HISTORY

Introduced as alpha in Kubernetes v1.19, beta in v1.20, stable in v1.23. Replaces deprecated 'kubectl get events' for dynamic watching.

SEE ALSO

kubectl get(1), kubectl describe(1), kubectl logs(1)

Copied to clipboard