Forrest logo
back to the kubectl tool

kubernetes:warp:ef853

Sort Kubernetes pods by age
$ kubectl get po --sort-by=.status.startTime
try on your machine

The command "kubectl get po" is used to retrieve information about the running pods in a Kubernetes cluster.

In this specific command, the "--sort-by=.status.startTime" flag is added to sort the output based on the start time of the pods. This flag allows you to view the pods in ascending order of their start time.

By default, the output of the "kubectl get po" command is not sorted. However, with the "--sort-by" flag, you can provide a field reference to specify the key by which the output should be sorted. In this case, the key is ".status.startTime", which corresponds to the start time of the pods.

After running the command, you will see the list of pods in ascending order, based on their start time. The most recently created pods will appear at the bottom of the list.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the kubectl tool