Labels and Selectors

View saved

Labels are key=value tags

Attach meaningful labels such as app=web or tier=frontend.

kubectl label pod web env=dev
kubectl get pods -l env=dev

Selectors connect pieces

A Service selects pods whose labels match. Deployments use matchLabels for their pods.

Inspect labels

See labels on listings.

kubectl get pods --show-labels
kubectl get svc web -o wide

Keep them consistent

Agree on a small label scheme early. Random labels make debugging harder.

Comments

One comment per signed-in account. Comments are saved with this page’s URL.