<p>When I run:</p>
<pre><code>kubectl get pods --field-selector=status.phase=Running
</code></pre>
<p>I see:</p>
<pre><code>NAME          READY   STATUS    RESTARTS   AGE
k8s-fbd7b     2/2     Running   0          5m5s
testm-45gfg   1/2     Error     0          22h
</code></pre>
<p>I don't understand why this command gives me pod that are in Error status?
According to <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase" rel="nofollow noreferrer">K8S api</a>, there is no such thing <code>STATUS=Error</code>.</p>
<p>How can I get only the pods that are in this Error status?</p>
<p>When I run:</p>
<pre><code>kubectl get pods --field-selector=status.phase=Failed
</code></pre>
<p>It tells me that there are no pods in that status.</p>

Slava
<p>Using the <code>kubectl get pods --field-selector=status.phase=Failed</code> command you can display all Pods in the <code>Failed</code> phase.</p>
<p><code>Failed</code> means that all containers in the Pod have terminated, and at least one container has terminated in failure (see: <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase" rel="noreferrer">Pod phase</a>):</p>
<blockquote>
<p>Failed - All containers in the Pod have terminated, and at least one container has terminated in failure. That is, the container either exited with non-zero status or was terminated by the system.</p>
</blockquote>
<p>In your example, both Pods are in the <code>Running</code> phase because at least one container is still running in each of these Pods.:</p>
<blockquote>
<p>Running - The Pod has been bound to a node, and all of the containers have been created. At least one container is still running, or is in the process of starting or restarting.</p>
</blockquote>
<p>You can check the current phase of Pods using the following command:</p>
<pre><code>$ kubectl get pod -o=jsonpath='{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.status.phase}{&quot;\n&quot;}{end}'
</code></pre>
<p>Let's check how this command works:</p>
<pre><code>$ kubectl get pods
NAME    READY   STATUS   
app-1   1/2     Error   
app-2   0/1     Error   

$ kubectl get pod -o=jsonpath='{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.status.phase}{&quot;\n&quot;}{end}'
app-1   Running
app-2   Failed
</code></pre>
<p>As you can see, only the <code>app-2</code> Pod is in the <code>Failed</code> phase. There is still one container running in the <code>app-1</code> Pod, so this Pod is in the <code>Running</code> phase.</p>
<p>To list all pods with the <code>Error</code> status, you can simply use:</p>
<pre><code>$ kubectl get pods -A | grep Error
default       app-1   1/2     Error     
default       app-2   0/1     Error
</code></pre>
<p>Additionally, it's worth mentioning that you can check the state of all containers in Pods:</p>
<pre><code>$ kubectl get pod -o=jsonpath='{range .items[*]}{.metadata.name}{&quot;\t&quot;}{.status.containerStatuses[*].state}{&quot;\n&quot;}{end}'
app-1   {&quot;terminated&quot;:{&quot;containerID&quot;:&quot;containerd://f208e2a1ff08c5ce2acf3a33da05603c1947107e398d2f5fbf6f35d8b273ac71&quot;,&quot;exitCode&quot;:2,&quot;finishedAt&quot;:&quot;2021-08-11T14:07:21Z&quot;,&quot;reason&quot;:&quot;Error&quot;,&quot;startedAt&quot;:&quot;2021-08-11T14:07:21Z&quot;}} {&quot;running&quot;:{&quot;startedAt&quot;:&quot;2021-08-11T14:07:21Z&quot;}}
app-2   {&quot;terminated&quot;:{&quot;containerID&quot;:&quot;containerd://7a66cbbf73985efaaf348ec2f7a14d8e5bf22f891bd655c4b64692005eb0439b&quot;,&quot;exitCode&quot;:2,&quot;finishedAt&quot;:&quot;2021-08-11T14:08:50Z&quot;,&quot;reason&quot;:&quot;Error&quot;,&quot;startedAt&quot;:&quot;2021-08-11T14:08:50Z&quot;}}
</code></pre>
