Exercise

  1. List all the events in the cluster

  2. List the same events sorted by the creationTimestamp

  3. Create a pod named www based on nginx

  4. List the events related to this Pod only

  5. List all the events related to the Created reason

  6. List all the events related to a type different from Normal

Documentation

https://kubernetes.io/docs/reference/kubectl/generated/kubectl_events/

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