Labels and Selectors: Equality-Based vs Set-Based Selection
Identify and Group Resources Meaningfully Kubernetes uses labels to describe resources and selectors to find them. Selectors come in two main forms: Equality-based selectors Set-based selectors Understanding when to use each is essential for scalable Kubernetes designs. Equality-Based Selectors Equality-based selectors match objects with exact label key–value pairs . Supported operators: = or == != (CLI only) Example selector: matchLabels: app: color-api tier: backend This selector matches only Pods that have both labels. Set-Based Selectors Set-based selectors allow matching based on sets of values or label existence . Supported operators: In NotIn Exists DoesNotExist Example: Multiple Values selector: matchExpressions: - key: tier operator: In values: - frontend - backend Example: Excluding Canary Releases selector: matchExpressions: - key: release oper...