In addition to filtering by event type using --field-selector, you can filter Kubernetes events by several other fields. Here are some common fields you can use:
-
involvedObject: Filter events based on the object that the event is related to. You can specify the kind and name of the object.
- Example:
involvedObject.kind=Pod,involvedObject.name=my-pod
- Example:
-
reason: Filter events based on the reason for the event.
- Example:
reason=Failed
- Example:
-
source: Filter events based on the source of the event, such as the component that generated it.
- Example:
source.component=kubelet
- Example:
-
metadata.namespace: Filter events based on the namespace in which the event occurred.
- Example:
metadata.namespace=my-namespace
- Example:
-
metadata.name: Filter events based on the name of the event.
- Example:
metadata.name=my-event
- Example:
You can combine multiple filters using commas to narrow down the results further. For example:
kubectl get events --field-selector involvedObject.kind=Pod,involvedObject.name=my-pod,type=Warning
This command will return only the warning events related to the specified pod.
Keep in mind that the availability of certain fields may depend on the specific version of Kubernetes you are using.
