kubectl - How to get the list of all pods that have been restarted at least once

Viewed 858

kubectl get pods --all-namespaces provides the list of all pods. The column RESTARTS shows the number of restarts that a pod has had. How to get the list of all the pods that have had at least one restart? Thanks

1 Answers
kubectl get pods --all-namespaces | awk '$5>0'

or simply just

kubectl get po -A | awk '$5>0'

Use awk to print if column 5 (RESTARTS) > 0

or with use of an alias

alias k='kubectl'
k get po -A | awk '$5>0'
Related