Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify pod which is not in a Ready state

Tags:

kubernetes

We have deployed a few pods in cluster in various namespaces. I would like to inspect and identify all pod which is not in a Ready state.

 master $ k get pod/nginx1401 -n dev1401
 NAME        READY   STATUS    RESTARTS   AGE
 nginx1401   0/1     Running   0          10m

In above list, Pod are showing in Running status but having some issue. How can we find the list of those pods. Below command not showing me the desired output:

 kubectl get po -A | grep Pending Looking for pods that have yet to schedule

 kubectl get po -A | grep -v Running Looking for pods in a state other than Running     

 kubectl get pods --field-selector=status.phase=Failed
like image 263
sachin Avatar asked Dec 19 '25 10:12

sachin


1 Answers

There is a long-standing feature request for this. The latest entry suggests

kubectl get po --all-namespaces | gawk 'match($3, /([0-9])+\/([0-9])+/, a) {if (a[1] < a[2] && $4 != "Completed") print $0}'

for finding pods that are running but not complete.

There are a lot of other suggestions in the thread that might work as well.

like image 153
michaelrp Avatar answered Dec 21 '25 14:12

michaelrp