<p>I am searching for a way to get the numbers of currently healthy running pods, with this command:</p>

<pre><code>kubectl get hpa -o=jsonpath='{.items[0].status.currentReplicas}'
</code></pre>

<p>I get the count of all pods regardless of whether the pod is running healthy or for example a pod has Insufficient CPU.</p>

Java
<p>If you need the running pods, you can do this:</p>

<p><code>kubectl get pods --field-selector=status.phase=Running</code></p>

<p>If what you want is the <strong>number</strong>, like integer number of running pods, you can add:</p>

<p><code>kubectl get pods --field-selector=status.phase=Running --no-headers=true | wc -l</code></p>
