Exercise
-
List all the events in the cluster
-
List the same events sorted by the creationTimestamp
-
Create a pod named www based on nginx
-
List the events related to this Pod only
-
List all the events related to the Created reason
-
List all the events related to a type different from Normal
Documentation
https://kubernetes.io/docs/reference/kubectl/generated/kubectl_events/
Solution
- List all the events in the cluster
k get events -A
- List the same events sorted by the creationTimestamp
k get events --sort-by={.metadata.creationTimestamp}
- Create a pod named www based on nginx
k run www --image=nginx:1.24
- List the events related to this Pod only
k get events --field-selector involvedObject.name=www
- List all the events related to the Created reason
k get events --field-selector reason=Created
- List all the events related to a type different from Normal
k get events --field-selector type!=Normal