An equality-based label selector filters Kubernetes objects by requiring a label value to equal or not equal a specified value. Labels become operational when selectors use them to identify a subset of objects for management tasks. section 7.3
Use equality-based selectors to express straightforward label conditions:
- app=quote selects objects whose app label equals quote. section 7.3
- app!=quote selects objects whose app label does not equal quote. section 7.3
- Separate selectors with commas to require every condition; app=quote,rel=canary selects only objects matching both labels. section 7.3
Filtering and deleting matching pods
Run kubectl get pods -l app=quote to list only Quote pods. Add rel=canary as kubectl get pods -l app=quote,rel=canary to narrow the result to the Quote canary. The same selection mechanism can remove matching objects with kubectl delete pods -l rel=canary. section 7.3.1
A nodeSelector is a manifest-level use of equality matching. Each specified node label must match exactly, and nodeSelector cannot express not-equal or set-based conditions; node affinity provides more expressive alternatives. section 7.3.2
