liveBook · Manning

Label

As explained in Road to Kubernetes

A metadata label is a key-value annotation attached to a Kubernetes resource for identification and filtering.

A label is a key-value annotation added to a Kubernetes resource’s metadata. Labels identify resources and let kubectl filter them; Services also use matching labels to find and attach to Pods. section 8.3.2

Apply labels in a manifest, then query matching resources with a selector:

Connecting an NGINX Pod to a Service

Add app: my-nginx under the Pod manifest’s metadata, apply the updated manifest with kubectl apply, and verify it with kubectl get pods my-nginx -o yaml. A Service using selector app: my-nginx can then find the labeled Pod. section 8.3.2

How Road to Kubernetes covers it

How deep it goes
Defines key-value labels and demonstrates metadata placement, verification, selectors, and Service matching.
Examples
Uses an NGINX Pod labeled app: my-nginx and kubectl commands that filter Pods, Services, and Deployments.
What you can do after
Operate/configure it by labeling manifests, verifying labels, and filtering resources with kubectl selectors.
How it connects
Connects Kubernetes manifests, Pods, Services, Deployments, kubectl, and selectors.

Also explained in

Compare how 7 books explain label →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.