Skip to content
masterclass Buddy

Kubernetes · Concept

Node affinity

Node affinity lets you control Pod placement using node labels. Required rules restrict scheduling; preferred rules influence placement without making a match mandatory.

Last updated

Syntax

spec.affinity.nodeAffinity:
  requiredDuringSchedulingIgnoredDuringExecution:
    nodeSelectorTerms: []
  preferredDuringSchedulingIgnoredDuringExecution:
  - weight: 1
    preference: {}

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • nodeSelector
  • podAffinity
  • podAntiAffinity
  • nodeName
  • Pod topology spread constraints
  • taints and tolerations

Source: Assigning Pods to Nodes | Kubernetes. Checked 2026-11-03.