<p>I am using kubectl in order to retrieve a list of pods:</p>

<pre><code> kubectl get pods --selector=artifact=boot-example -n my-sandbox  
</code></pre>

<p>The results which I am getting are:</p>

<pre><code>NAME                           READY   STATUS    RESTARTS   AGE
boot-example-757c4c6d9c-kk7mg   0/1     Running   0          77m
boot-example-7dd6cd8d49-d46xs   1/1     Running   0          84m
boot-example-7dd6cd8d49-sktf8   1/1     Running   0          88m
</code></pre>

<p>I would like to get only those pods which are "<strong>ready</strong>" (passed readinessProbe). Is there any kubectl command which returns only "<strong>ready</strong>" pods? If not kubectl command, then maybe some other way?</p>

fascynacja
<p>You can use this command:</p>
<pre><code>kubectl -n your-namespace get pods -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready | grep true
</code></pre>
<p>This will return you the pods with containers that are &quot;<strong>ready</strong>&quot;.</p>
<p>To do this without grep, you can use the following commands:</p>
<pre><code>kubectl -n your-namespace get pods -o go-template='{{range $index, $element := .items}}{{range .status.containerStatuses}}{{if .ready}}{{$element.metadata.name}}{{&quot;\n&quot;}}{{end}}{{end}}{{end}}'

kubectl -n your-namespace get pods -o jsonpath='{range .items[*]}{.status.containerStatuses[*].ready.true}{.metadata.name}{ &quot;\n&quot;}{end}'
</code></pre>
<p>This will return you the pod names that are &quot;<strong>ready</strong>&quot;.</p>
