How can the OR selector be used with labels in Kubernetes?

9/3/2017

How the OR expression can be used with selectors and labels?

  selector:
    app: myapp
    tier: frontend

The above matches pods where labels app==myapp AND tier=frontend.

But the OR expression can be used?

app==myapp OR tier=frontend?

-- Tevin J
kubernetes

2 Answers

8/29/2018

OR isn't supported in your case.

You can try the set-based label selector. Refer to the following link, https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#resources-that-support-set-based-requirements

-- Benjamin
Source: StackOverflow

5/21/2019

Now you can do that :

kubectl get pods -l 'environment in (production, qa)'

https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering

-- Pasc23
Source: StackOverflow