A label selector operator defines how Kubernetes compares a label key with one or more values. It lets scheduling rules require, exclude, detect, or numerically compare labels. section 7.3.2
Set-based selector expressions support these operators:
- In requires a label value to match one listed value; NotIn excludes listed values. section 7.3.2
- Exists requires the label key, while DoesNotExist requires that the key be absent. section 7.3.2
- Lt and Gt compare a label value with one numeric value. section 7.3.2
- Omit values for Exists and DoesNotExist; provide exactly one value for Lt and Gt. section 7.3.2
Exclude labeled nodes
A node-affinity rule can require node-role=front-end while excluding nodes carrying skip-me. If every matching node has skip-me=true, the pod remains Pending. 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
...
Shows a set-based selector combining In and DoesNotExist in node affinity. section 7.3.2
