Search code examples
kuberneteskubectlkubernetes-pod

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


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


Solution

  • 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'