Kubernetes sorts containers by age

I can sort my Cuban cubes by name using:

kubectl get pods --sort-by=.metadata.name 

How can I sort them (or other resources) by age using kubectl ?

+7
kubernetes kubectl
source share
1 answer

Pods have a status that you can use to find out startTime.

I think something like kubectl get po --sort-by=.status.startTime should work.

You can also try kubectl get po --sort-by='{.firstTimestamp}' .

Also, apparently, version 1.7 cancels sorting.

https://github.com/kubernetes/kubectl/issues/43

Here's the error report: https://github.com/kubernetes/kubernetes/issues/48602

Here's the PR: https://github.com/kubernetes/kubernetes/pull/48659/files

+11
source share

All Articles