<p>Is it possible to do <code>kubectl get pods -l foo=bar||a=b</code> instead of <code>kubectl get pods -l foo=bar -l a=b</code>, which gives you <code>and</code> instead of <code>or</code>?</p>
<p>I've played around with set-based requirements, but can't seem to quite get the desired result:</p>
<pre><code>$ kubectl get pods -l 'app in (microbot, foo)' -A
NAMESPACE   NAME                        READY   STATUS    RESTARTS   AGE
default     microbot-657fc66cc6-f4ll7   1/1     Running   0          18h
</code></pre>
<p>But, if I try and use multiple headers too</p>
<pre><code>$ kubectl get pods -l 'app,k8s-app in (microbot, foobar)' -A
No resources found
</code></pre>

joedborg
<p>It seem this is not supported.</p>
<p>However, you could use the <code>custom-columns</code> output format (details <a href="https://kubernetes.io/docs/reference/kubectl/overview/#custom-columns" rel="nofollow noreferrer">here</a>) to get there:</p>
<pre><code>kubectl get pods -o custom-columns=NAME:.metadata.name,LABELS:.metadata.labels -A | grep &quot;key1:value1\|key2:value2&quot;
</code></pre>
<p>You might need to be careful the key:value pairs don't appear in undesired pods in any custom-columns you do choose for this initial output. I.e. if you chose a selector as a column, that might lead to problems with pods that reference the desired pods and might require a bit more sophistication in the query/grep.</p>
