<p>Hi I am having a shell script.</p>
<p>i am trying the following command to get a pod name</p>
<pre><code>K6_POD=$(kubectl get pod -l 'app.kubernetes.io/component=k6' -n k6 -o jsonpath=&quot;{.items[0].metadata.name}&quot;)
</code></pre>
<p>however with the above command,  it returns the name of a terminating pod instead of a pod with status Running
appreciate if you can help</p>

Starbucks Admin
<p>You can add the <code>--field-selector</code> flag e.g. <code>kubectl get pods --field-selector=status.phase=Running</code></p>
<p>source: <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/kubectl/cheatsheet/</a></p>
