Logical operation of a k8s multi-entry selector

5/10/2020

This k8s service definition have multiple entries under selector section.

apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: my-app tier: back-end ports: - protocol: TCP port: 80 targetPort: 9376

Which operation does this selector follows, ( app == my-app && tier == back-end ) or ( app == my-app || tier == back-end )?

-- Yasir
kubernetes

1 Answer

5/10/2020

From the docs here

A label selector can be made of multiple requirements which are comma-separated. In the case of multiple requirements, all must be satisfied so the comma separator acts as a logical AND (&&) operator.

Caution: For both equality-based and set-based conditions there is no logical OR (||) operator. Ensure your filter statements are structured accordingly

-- Arghya Sadhu
Source: StackOverflow