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

5/19/2021

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

-- imriss
kubectl
kubernetes
kubernetes-pod

1 Answer

5/19/2021
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

-- Rakesh Gupta
Source: StackOverflow