liveBook · Manning

Affinity

As explained in Effective Platform Engineering

Node affinity is a Kubernetes scheduling constraint that attracts pods to nodes matching specified labels.

Node affinity is a Kubernetes scheduling constraint that attracts pods to nodes matching specified labels, such as a management role or hardware characteristic. section 7.4.6

Configure affinity with label selectors in the pod YAML. Unlike tolerations, which allow placement onto tainted nodes, affinity pulls workloads toward nodes with desired labels; together they provide fine-grained placement control. section 7.4.6

Pin a storage test pod to management nodes

Set requiredDuringSchedulingIgnoredDuringExecution with a nodeSelectorTerm matching node.kubernetes.io/role=management. The accompanying toleration permits placement on management nodes tainted with dedicated=management:NoSchedule.

Validate the placement pattern by:

  • Deploying the pod with the EBS volume fixture. section 7.4.6
  • Deleting all deployed test resources after verification. section 7.4.6

How Effective Platform Engineering covers it

How deep it goes
Defines label-based placement and shows a required scheduling manifest, but does not detail scheduler internals.
Examples
Uses a management-node storage pod that mounts EBS-backed storage and is checked with kubectl and Bats.
What you can do after
Configure pod placement with label selectors and verify scheduling and mounted-volume writes through Kubernetes tests.
How it connects
Connects node affinity with node labels, tolerations, taints, Karpenter, persistent volumes, and Kubernetes pod scheduling.

Also explained in

Compare how 6 books explain affinity →

Related concepts

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