✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Kubernetes Node Label Usage

Kubernetes Node Labels are used to categorize and select nodes for scheduling pods, enabling efficient resource management and workload placement in a cluster.

Kubernetes Node Label Usage is the application of labels to Node objects themselves, serving a purpose distinct from Pod labels in that node labels describe the characteristics and identity of the underlying infrastructure a workload might run on, consumed primarily by scheduling constraints — node selectors and node affinity rules — rather than by Service routing or ownership selectors, making node labels the primary vocabulary through which Pods express requirements about where in the cluster's physical or virtual topology they should be placed.


Built-In Node Labels

Topology Labels

Kubernetes automatically populates a set of well-known topology labels on every node, including topology.kubernetes.io/region and topology.kubernetes.io/zone, sourced from cloud provider integrations or manually set in on-premises environments, giving the scheduler and topology-aware features a standard vocabulary for reasoning about geographic or infrastructure placement without requiring cluster-specific label conventions.

Instance and Hardware Labels

Additional built-in labels such as kubernetes.io/hostname, kubernetes.io/os, and kubernetes.io/arch describe intrinsic node characteristics — the node's own name, operating system, and CPU architecture — automatically set by the kubelet at node registration and generally not intended to be manually overridden, since they reflect facts about the node the kubelet itself is authoritative over.

Instance Type Labels From Cloud Integrations

Cloud provider integrations commonly add further labels describing the node's underlying instance type or machine family, letting Pods with specific hardware requirements (such as needing a GPU-equipped instance type) express that requirement through a node selector or affinity rule referencing the appropriate label.


Custom Node Labels

Administrator-Applied Labels for Workload Placement

Beyond the automatically populated set, cluster administrators commonly apply custom labels to nodes to express operationally meaningful groupings not captured by built-in labels — a label marking nodes reserved for a specific team, nodes belonging to a particular hardware generation, or nodes designated for batch versus latency-sensitive workloads.

Labeling as Part of Node Provisioning

In clusters using infrastructure-as-code to provision nodes, custom labels are typically applied automatically as part of the node's initial registration through whatever provisioning tool or node pool configuration created it, rather than being applied manually after the fact, ensuring consistency across nodes created through the same provisioning path.


Consuming Node Labels for Scheduling

nodeSelector as the Simple Form

A Pod's spec.nodeSelector is a plain equality-based map matched directly against node labels, functioning as the simplest way to constrain a Pod to nodes carrying specific label values, structurally similar to a Service's selector in its restriction to equality-only matching.

Node Affinity for Expressive Constraints

Node affinity rules, expressed through spec.affinity.nodeAffinity, support the fuller matchExpressions syntax including set-based and existence operators, along with a distinction between hard requirements (requiredDuringSchedulingIgnoredDuringExecution) and soft preferences (preferredDuringSchedulingIgnoredDuringExecution), giving Pod placement far more nuanced control over node labels than nodeSelector's simple equality matching allows.


Node Labels and Topology-Aware Features

Pod Topology Spread Constraints

Beyond direct placement targeting, node topology labels feed into pod topology spread constraints, which distribute a workload's Pods evenly across whatever topology domain a specified label key represents (such as spreading across zones), using the same label vocabulary but for balance rather than for a hard placement requirement.

Volume Topology Awareness

Storage provisioning also consumes node topology labels, since a CSI driver's volume binding logic often needs to ensure a dynamically provisioned volume is created in the same zone as the node a Pod using it will actually be scheduled to, tying node labeling directly into correct, zone-aware storage behavior as well as compute placement.