<p><a href="https://i.stack.imgur.com/o5Czz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o5Czz.png" alt="enter image description here" /></a></p>
<p>I have a <a href="https://k3s.io/" rel="nofollow noreferrer">k3s</a> cluster with some pods running. I want to get all pods with status of <em>Running</em> containing <em>grafana</em> in its name.</p>
<p>From the docs, looks like I can use <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/" rel="nofollow noreferrer">field selector</a> flag to achieve it (<a href="https://github.com/kubernetes/kubernetes/pull/50140?w=1" rel="nofollow noreferrer">was introduced in v1.9 release</a>). But when I give it a try, it didn't work.</p>
<p>I know I can force delete the pod with <em>Terminating</em> status to get what I want. What I want to know here is, why my command didn't work as expected? Did i miss something?</p>
<p>Btw, the <em>Terminating</em> pod was there for some time. I believe it's stuck. But again, that's not the interest of this question.</p>

Zulhilmi Zainudin
<p>If you take a look into <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase" rel="nofollow noreferrer">k8s documentation on pod-lifecycle</a> you can see that status.phase can have only 5 different values and none of them is  <code>Terminating</code>. This means that termination state in not reflected in this field and therefore filtering by the phase field is useless.</p>
<p>Terminating status is reflected under <code>.status.containerStatuses.state</code> (<a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states" rel="nofollow noreferrer">container states in docs</a>) although this field label doesn't seem to be supported by the filter.</p>
<hr />
<p>So what can you do?</p>
<p>The easiest thing you can do is to use grep twice:</p>
<pre><code>kubectl get pods | grep grafana | grep Running
</code></pre>
