11

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
  • 1,815
  • 4
  • 31
  • 46

1 Answers1

19
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 the use of an alias

alias k='kubectl'
k get po -A | awk '$5>0'
Rakesh Gupta
  • 3,507
  • 3
  • 18
  • 24
  • 1
    Thanks. I will accept your answer. I would also like to see an answer based on the `kubectl` options without post processing. – imriss May 19 '21 at 23:37