<p>I am trying to get a list of all non-READY containers in all pods to debug a networking issue in my cluster.</p>

<p>Is it possible to use kubectl to get a clean list of all containers in all pods with their status (READY/..)?</p>

<p>I am currently using</p>

<pre><code>$ kubectl get pods 
</code></pre>

<p>However, the output can be huge and it can be difficult to know which containers are READY and which ones have issues.</p>

<p>Thanks.</p>

<p><code>kubectl get pods -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .status.containerStatuses[*]}{.ready}{", "}{end}{end}'</code></p>

<p>Adapted from this doc: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/list-all-running-container-images/#list-containers-by-pod" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/access-application-cluster/list-all-running-container-images/#list-containers-by-pod</a></p>

<p><strong>Edit</strong> to describe what the jsonpath is doing:</p>

<p>From what I understand with the jsonpath, range iterates all of the .items[*] returned by getting the pods. \n is added to split the result to one per line, otherwise the result would come to one line. To see how the rest work, you should choose one of your pods and run:
<code>kubectl get pod podname -o yaml</code><br>
.metadata.name corresponds to</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: podname
</code></pre>

<p>Similarly, .status.containerStatuses[*] corresponds to the list of container statuses that should be towards the bottom. </p>
