Node affinity constrains Pods to labeled nodes as a hard rule or a weighted preference
Answer: Node affinity lets you constrain a Pod to run on particular nodes, or to prefer particular nodes, by matching node labels. Use requiredDuringSchedulingIgnoredDuringExecution for a hard rule and preferredDuringSchedulingIgnoredDuringExecution with a weight for a preference.
When to bother
Often you do not need any constraints; the scheduler will automatically do a reasonable placement. Constrain placement when a Pod must end up on a node with an SSD attached, or to co-locate Pods from two services that communicate a lot into the same availability zone. The options are the nodeSelector field, affinity and anti-affinity, the nodeName field, and Pod topology spread constraints.
The two rule types
requiredDuringSchedulingIgnoredDuringExecution: the scheduler can't schedule the Pod unless the rule is met. Withdisktype: ssd, the pod will get scheduled only on a node that has adisktype=ssdlabel.preferredDuringSchedulingIgnoredDuringExecution: the scheduler tries to find a node that meets the rule, and still schedules the Pod if no matching node is available.
IgnoredDuringExecution means that if the node labels change after Kubernetes schedules the Pod, the Pod keeps running.
Weights
You can specify a weight between 1 and 100 for each preferred rule. The weight is added to the other scores for a matching node, and the Pod goes onto the node with the highest final score.
See also
Claims
- id: C1 claim: Required rules block scheduling until met. source: S1 evidence: "The scheduler can't schedule the Pod unless the rule is met."
- id: C2 claim: Preferred-rule weights range from 1 to 100. source: S1 evidence: "You can specify a weight between 1 and 100"
- id: C3 claim: Preferred rules try to find a matching node. source: S1 evidence: "The scheduler tries to find a node that meets the rule."
- id: C4 claim: A required disktype=ssd rule schedules only on matching nodes. source: S2 evidence: "the pod will get scheduled only on a node that has a"
Sources
- [S1] Assigning Pods to Nodes. Kubernetes docs. https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/ . License: CC-BY-4.0. Accessed 2026-11-18.
- [S2] Assign Pods to Nodes using Node Affinity (source page). kubernetes/website (GitHub). https://github.com/kubernetes/website/blob/main/content/en/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity.md . License: CC-BY-4.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Assigning Pods to Nodes; kubernetes/website (GitHub), Assign Pods to Nodes using Node Affinity (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Assigning Pods to Nodes; kubernetes/website (GitHub), Assign Pods to Nodes using Node Affinity (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.
Cite this
iinventedlight. 2026. "Node affinity constrains Pods to labeled nodes as a hard rule or a weighted preference." iinventedlight Library, iil:note:kpwkd5bh, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-node-affinity/. License: CC-BY-4.0.
@misc{iil_note_kpwkd5bh,
author = {{iinventedlight}},
title = {{Node affinity constrains Pods to labeled nodes as a hard rule or a weighted preference}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/kubernetes-node-affinity/},
note = {Permanent ID iil:note:kpwkd5bh. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-node-affinity.md.