liveBook · Manning

Topology key

As explained in Kubernetes for Developers

A topology key is a node-label key whose values define the topology domains considered equivalent for spreading workloads.

A topology key selects the node-label values Kubernetes treats as equivalent domains when spreading Pods. Using kubernetes.io/hostname makes each uniquely labeled node a separate spreading domain. section 8.2.1

Use a topology key with topology spread constraints to control placement:

  • Verify that every target node has the selected label; Kubernetes platforms are not guaranteed to provide even well-known labels. section 8.2.1
  • Choose kubernetes.io/hostname for node-level spreading, then control imbalance with maxSkew and failure behavior with whenUnsatisfiable. section 8.2.1

Spreading three replicas across nodes

A Deployment with three replicas, topologyKey kubernetes.io/hostname, maxSkew 1, and ScheduleAnyway asks Kubernetes to distribute replicas across labeled nodes while still scheduling when perfect spreading is impossible.

How Kubernetes for Developers covers it

How deep it goes
Explains node-level placement, label verification, imbalance limits, and unsatisfied-constraint behavior.
Examples
Uses kubernetes.io/hostname in a three-replica timeserver Deployment and verifies placement with kubectl.
What it assumes
Requires understanding that topology keys reference node labels and that kubectl can inspect those labels.
What you can do after
Configure node-level workload spreading and verify the required node labels before deployment.
How it connects
Connects topology spread constraints with node labels, Pods, scheduling, and Deployments.

Also explained in

Compare how 2 books explain topology key →

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.