label selector

A query that picks objects by their labels, such as every pod with app=web; controllers and Services depend on it.

In more detail

A selector is a contract: a Deployment's selector must match the labels in its pod template, or the count never settles. A Service with a selector that matches nothing has no endpoints and times out. On the command line, -l applies a selector to kubectl.

Examples

selector:
  matchLabels:
    app: web
kubectl get pods -l app=web

Related terms

Taught in

References

Certification courses