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

A better way to specify the JSON path is:

kubectl get pods -n kube-system --sort-by='{.metadata.creationTimestamp}'