How to Sort Pods by CreationTimestamp in Kubernetes

If you need to sort a list of your pods by their CreationTimestamp, then do the following:

kubectl get pods -n kube-system --sort-by=metadata.creationTimestamp
Code language: Bash (bash)

A better way to specify the JSON path is:

kubectl get pods -n kube-system --sort-by='{.metadata.creationTimestamp}'
Code language: Bash (bash)

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments