Get name of most recently created pod Get name of most recently created pod kubernetes kubernetes

Get name of most recently created pod


Try this:

kubectl get pods --sort-by=.metadata.creationTimestamp -o jsonpath="{.items[0].metadata.name}"


On Kubernetes front, kubectl get po --sort-by=.status.startTime is supposed to work, except in K8s 1.7: it was fixed for 1.8.

"Kubernetes sort pods by age" also mentions

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

Since Openshift 3.9 (March 2018) is fairly recent, those kubectl commands should work even if the oc one is not fully compatible.