<p>I wanted to hit a command which searches pod with the service name and identify its pod's status as &quot;Ready&quot;</p>
<p>I tried some of the commands but it does not work and it does not search with service-name.</p>
<pre><code>kubectl get svc | grep my-service | --output=&quot;jsonpath={.status.containerStatuses[*].ready}&quot; | cut -d' ' -f2
</code></pre>
<p>I tried to use the loop also, but the script does not give the desired output.</p>
<p>Can you please help me figure out the exact command?</p>

<p>If I understood you correctly, you want to find if specific <code>Pod</code> connected to specific <code>Endpoint</code> - is in <code>&quot;Ready&quot;</code> status .</p>
<p>Using <code>JSON PATH</code> you can display all <code>Pods</code> in specific <code>namespace</code> with their status:<br></p>
<pre><code>$ kubectl get pod -o=jsonpath='{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.status.phase}{&quot;\n&quot;}{end}'
</code></pre>
<p>If you are looking for status for <code>Pods</code> connected to specific <code>Endpoint</code>, you can use below script:</p>
<pre><code>#!/bin/bash

endpointName=&quot;web-1&quot;

for podName in $(kubectl get endpoints  $endpointName -o=jsonpath={.subsets[*].addresses[*].targetRef.name}); do
    if [ ! -z $podName ]; then
        kubectl get pod -o=jsonpath='{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.status.phase}{&quot;\n&quot;}{end}' | grep $podName
    fi
done

for podName in $(kubectl get endpoints  $endpointName -o=jsonpath={.subsets[*].notReadyAddresses[*].targetRef.name}); do
    if [ ! -z $podName ]; then
        kubectl get pod -o=jsonpath='{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.status.phase}{&quot;\n&quot;}{end}' | grep $podName
    fi
done
</code></pre>
<p>Please note that you need to change <code>Endpoint</code> name to your needs, in above example I use <code>web-1</code> name.</p>
<p>If this response doesn't answer your question, please specify your exact purpose.</p>
