<p>I want to write a wrapper on <code>kubectl</code> to display only failed pods which means it should only display items whose Ready column values are not the same (i.e <code>0/1, 0/2, 1/2, 2/3,</code> etc.)</p>

<pre><code>$ kubectl get pods --all-namespaces
NAMESPACE       NAME                                        READY     STATUS             RESTARTS   AGE
default         pod-with-sidecar                            1/2       ErrImagePull       0          39s
kube-system     calico-node-chcqq                           2/2       Running            2          7d
kube-system     calico-policy-controller-6449789dd6-z5t5j   1/1       Running            0          7d
kube-system     etcd                                        1/1       Running            0          7d
kube-system     kube-apiserver                              1/1       Running            2          7d
kube-system     kube-controller-manager                     1/1       Running            0          7d
kube-system     kube-dns-5c76d6bddb-8zhmq                   3/3       Running            1          7d
kube-system     kube-proxy-xq8j6                            1/1       Running            0          7d
kube-system     kube-scheduler-                             1/1       Running            0          7d
kube-system     tiller-deploy-5b7cb9cfd7-j725s              1/1       Running            0          7d
my-system       glusterfs-brick-0                           0/2       Pending            0          3m
my-system       sticky-scheduler-6d968f8d74-xvjqn           0/1       ImagePullBackOff   0          4m
</code></pre>

<p>so from the above output i want to print these failed pods</p>

<pre><code>NAMESPACE       NAME                                        READY     STATUS             RESTARTS   AGE
default         pod-with-sidecar                            1/2       ErrImagePull       0          4m
my-system       glusterfs-brick-0                           0/2       Pending            0          56s
my-system       sticky-scheduler-6d968f8d74-xvjqn           0/1       ImagePullBackOff   0          8m
</code></pre>

<p>This works!</p>

<pre><code>$ kubectl get pods --all-namespaces | grep -vE '1/1|2/2|3/3'

NAMESPACE       NAME                                        READY     STATUS             RESTARTS   AGE
default         pod-with-sidecar                            1/2       ErrImagePull       0          4m
my-system       glusterfs-brick-0                           0/2       Pending            0          56s
my-system       sticky-scheduler-6d968f8d74-xvjqn           0/1       ImagePullBackOff   0          8m
</code></pre>

<p>But it won't work if i have <code>2/4,0/4,0/5,0/6</code> etc in the <code>Ready</code> column, what can i do with <code>grep -vE '1/1|2/2|3/3'</code> to make it work for all such cases</p>

<p>Reference: <a href="https://github.com/kubernetes/kubernetes/issues/49387" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/49387</a></p>

Bad_Coder
<p>You can do it by using <code>--field-selector</code>:</p>

<pre><code>kubectl get pods --all-namespaces --field-selector=status.phase!=Running
</code></pre>

<p><a href="https://github.com/kubernetes/kubernetes/issues/49387#issuecomment-346746104" rel="noreferrer">Source</a></p>
