Pods & Pixels

Pods & Pixels

Share this post

Pods & Pixels
Pods & Pixels
Kubernetes Affinity & Anti-Affinity Rules

Kubernetes Affinity & Anti-Affinity Rules

Christopher Adamson's avatar
Christopher Adamson
Jun 22, 2025
∙ Paid

Share this post

Pods & Pixels
Pods & Pixels
Kubernetes Affinity & Anti-Affinity Rules
Share

In Kubernetes, Affinity and Anti-Affinity are scheduling rules that control how pods are placed across nodes or in relation to other pods, enabling more intelligent workload distribution based on data locality, fault tolerance, or workload segregation. Think of them as "rules of attraction and repulsion"—Affinity expresses a desire for a pod to be near something (“I want to be close to something”), while Anti-Affinity expresses a desire to avoid proximity (“I want to avoid being near something”). These rules come in two main types: Node Affinity, which defines constraints on which nodes a pod can be scheduled to, and Pod Affinity/Anti-Affinity, which sets constraints based on the presence or absence of other pods.

Keep reading with a 7-day free trial

Subscribe to Pods & Pixels to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Christopher Adamson
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share