Linux command
kubectl-events 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show events
kubectl events
Show events
kubectl events -n [namespace]
Show events
kubectl events -A
Events scoped to a specific resource
kubectl events --for [pod/pod-name]
Watch live events
kubectl events --watch
Only Warnings
kubectl events --types=[Warning]
Sort events
kubectl events --sort-by=[lastTimestamp]
Output as JSON
kubectl events -o json
说明
kubectl events is the modern, dedicated subcommand for listing Kubernetes Event objects. It was added as an alpha in kubectl 1.23 and promoted to GA in 1.27, replacing the older kubectl get events form with a cleaner default output and live-watch support. Events are short-lived records emitted by controllers (kubelet, scheduler, controller-manager, custom operators, ...) that describe noteworthy state changes such as pod scheduling, image pulls, liveness-probe failures, or HPA scaling decisions. Use --for to follow a specific Pod, Deployment, or Job, --watch for live debugging, and --sort-by to put the most recent events at the bottom for chronological reading.
参数
- -n _NAMESPACE_
- Target namespace (default: current context's namespace).
- -A, --all-namespaces
- List events from every namespace.
- --for _KIND/NAME_
- Restrict to events whose involvedObject matches the given resource (e.g. pod/web-0).
- --watch, -w
- Stream new events instead of exiting after one snapshot.
- --types _TYPES_
- Comma-separated event types (Normal, Warning).
- --sort-by _FIELD_
- Sort by a JSONPath field, typically .lastTimestamp or .metadata.creationTimestamp.
- -o _FORMAT_
- Output format (wide, json, yaml, jsonpath, ...).
- --no-headers
- Suppress the column header line.
- --help
- Display help information.
FAQ
What is the kubectl-events command used for?
kubectl events is the modern, dedicated subcommand for listing Kubernetes Event objects. It was added as an alpha in kubectl 1.23 and promoted to GA in 1.27, replacing the older kubectl get events form with a cleaner default output and live-watch support. Events are short-lived records emitted by controllers (kubelet, scheduler, controller-manager, custom operators, ...) that describe noteworthy state changes such as pod scheduling, image pulls, liveness-probe failures, or HPA scaling decisions. Use --for to follow a specific Pod, Deployment, or Job, --watch for live debugging, and --sort-by to put the most recent events at the bottom for chronological reading.
How do I run a basic kubectl-events example?
Run `kubectl events` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n _NAMESPACE_ do in kubectl-events?
Target namespace (default: current context's namespace).