← All notes

Kubernetes labels, selectors and annotations

Answer:

Labels

metadata:
  labels:
    app: web
    tier: frontend
    environment: prod

Valid annotation keys have two segments: an optional prefix and name, separated by a slash (/). (S2) Labels do not have to be unique; many objects share a label.

Selectors

kubectl get pods -l 'app=web,environment in (prod)'

Annotations

metadata:
  annotations:
    example.com/git-commit: 1a2b3c

Rule of thumb

If you will select by it, make it a label. Otherwise, annotate.

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes Authors, Labels and Selectors, CC BY 4.0 (kubernetes/website); Kubernetes Authors, Annotations, CC BY 4.0 (kubernetes/website).

Cite this

Permanent ID: iil:note:ywp947qg

iinventedlight. 2026. "Kubernetes labels, selectors and annotations." iinventedlight Library, iil:note:ywp947qg, version of 2026-11-04. https://iinventedlight.com/library/notes/kubernetes-labels-selectors/. License: CC-BY-4.0.

@misc{iil_note_ywp947qg,
  author = {{iinventedlight}},
  title = {{Kubernetes labels, selectors and annotations}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/kubernetes-labels-selectors/},
  note = {Permanent ID iil:note:ywp947qg. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/kubernetes-labels-selectors.md.