5

Kubectl: Get Events & Sort By Time

 1 year ago
source link: https://www.shellhacks.com/kubectl-get-events-sort-by-time/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Kubectl: Get Events & Sort By Time

Kubernetes events are automatically created when resources have state changes, errors or other messages that should be broadcasted to the system.

These events (logs) are very helpful for debugging issues in a Kubernetes cluster.

Unfortunately, a kubectl get events command, by default, returns an unsorted list of the events that is not easy to search through.

This note shows how to get the events using the kubectl command and sort them by time.

Cool Tip: Get events from a specific Node using the kubectl command! Read more →

Kubectl: Get Events & Sort By Time

Run one of the commands below, to get events (logs) in a Kubernetes cluster, depending on a context:

$ kubectl get events
$ kubectl get events -n <namespaceName>
$ kubectl get events --all-namespaces

To set the events output format to a “wide”:

$ kubectl get events -o wide

To watch (tail) the events in a real time:

$ kubectl get events -w

To sort the events by time, execute one of the commands below:

$ kubectl get events --sort-by='.lastTimestamp'
- or -
$ kubectl get events --sort-by=.metadata.creationTimestamp

You can also combine these commands with -o wide and -w options to watch (tail) the events sorted by time with the extra details:

$ kubectl get events --sort-by='.lastTimestamp' -o wide -w
- or -
$ kubectl get events --sort-by=.metadata.creationTimestamp -o wide -w

Cool Tip: How to increase a verbosity of the kubectl command! Read more →


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK