← All notes

Kubernetes inter-pod affinity constrains Pods using other Pod labels

Answer: Inter-pod affinity and anti-affinity allow you to constrain Pods against labels on other Pods. A topologyKey is the key for the node label that denotes the domain. This is separate from nodeSelector, which only selects nodes with all the specified labels, and from node affinity, which uses a more expressive syntax on node labels.

Required and preferred rules

preferredDuringSchedulingIgnoredDuringExecution means the scheduler tries to find a node that meets the rule. A required rule must be met for the Pod to be scheduled. You can also specify node affinities using the .spec.affinity.nodeAffinity field in your Pod spec.

Notes

Kubernetes also populates a standard set of labels on all nodes in a cluster. If you use labels for node isolation, choose label keys that the kubelet cannot modify.

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, Assigning Pods to Nodes; kubernetes/website, Assigning Pods to Nodes (Kubernetes website source). 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, Assigning Pods to Nodes; kubernetes/website, Assigning Pods to Nodes (Kubernetes website source). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.

Cite this

Permanent ID: iil:note:s66hej51

iinventedlight. 2026. "Kubernetes inter-pod affinity constrains Pods using other Pod labels." iinventedlight Library, iil:note:s66hej51, version of 2026-11-23. https://iinventedlight.com/library/notes/kubernetes-inter-pod-affinity/. License: CC-BY-4.0.

@misc{iil_note_s66hej51,
  author = {{iinventedlight}},
  title = {{Kubernetes inter-pod affinity constrains Pods using other Pod labels}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/kubernetes-inter-pod-affinity/},
  note = {Permanent ID iil:note:s66hej51. 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).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-inter-pod-affinity.md.