liveBook · Manning

Label

As explained in Kubernetes for Developers

A Kubernetes label is an arbitrary key-value metadata pair attached to an object for identification and selection.

A Kubernetes label is an arbitrary key-value pair attached to an object. Other Kubernetes objects use matching labels to identify and select Pods or nodes. section 3.2.4 section 8.1.1

Labels provide the connection between a Deployment and the Pods it manages. The Deployment selector matches the labels on its Pod template, while Services and other objects can select those Pods directly. section 3.2.4 section 3.5

Use labels to:

  • Bind a Deployment selector to the Pods created from its Pod template. section 3.2.4
  • Expose or manage selected Pods through objects such as Services and Pod Disruption Budgets. section 3.2.4
  • Target nodes with particular features through a node selector or node affinity. section 8.1.1
  • Keep workloads separated by combining node labels and selectors with taints, tolerations, affinity, or anti-affinity. section 8.4

Selecting an Arm-based node

A workload can require the label kubernetes.io/arch: arm64 with nodeSelector. Kubernetes then schedules the Pod only on a node carrying that label. Node affinity expresses the same requirement more verbosely and supports more expressive logic. If no node has the required label, the Pod remains unscheduled. section 8.1.1 section 8.3

Figure 3.11 Relationship of the Deployment’s selector and the Pod template’s labels
03-11

The relationship diagram shows how a Deployment selector matches labels in its Pod template. section 3.2.4

How Kubernetes for Developers covers it

How deep it goes
Explains label matching, scheduling use, and a missing-label failure mode, but defers exhaustive label syntax and API reference.
Examples
Uses the pod: timeserver-pod match and the kubernetes.io/arch: arm64 scheduling requirement.
What it assumes
Assumes familiarity with Pods and deployments, while teaching label matching and node selection through concrete configurations.
What you can do after
Configure object relationships and node placement by assigning labels and matching them with selectors or affinity rules.
How it connects
Connects Deployments, Pods, Services, node selectors, node affinity, taints, tolerations, and Pod Disruption Budgets.

Also explained in

Compare how 7 books explain label →

Related concepts

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