A match expression is a node-affinity condition that combines a label key, an operator, and optional values. It selects nodes by testing their labels. section 7.3.2
Use these operators to define the label test:
- In or NotIn matches whether a label value belongs or does not belong to the values list. section 7.3.2
- Exists or DoesNotExist tests whether the label key is present; omit values. section 7.3.2
- Lt or Gt compares a label value with exactly one value. section 7.3.2
Exclude labelled nodes
A node-affinity rule can require node-role=front-end while excluding nodes labelled skip-me: true. Multiple nodeSelectorTerms use OR logic; multiple matchExpressions inside one term use AND logic. section 7.3.2
Listing 7.5 Using a set-based label selector
apiVersion: v1
kind: Pod
metadata:
name: kiada-front-end-affinity
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions: #1
- key: node-role #2
operator: In #2
values: #2
- front-end #2
- key: skip-me #3
operator: DoesNotExist #3
...
A manifest shows matchExpressions selecting front-end nodes whose skip-me label does not exist. section 7.3.2
