← All notes

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

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

Sources

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

Permanent ID: iil:note:kpwkd5bh

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.},
}

Markdown

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.