$linuxjunkies
>

anti-affinity

also: pod anti-affinity, node anti-affinity

A scheduling constraint that prevents certain processes or pods from running on the same host or node, used to distribute workloads across infrastructure for fault tolerance.

Anti-affinity is a scheduling policy that enforces separation of related workloads across different physical or virtual machines. Instead of grouping resources together, it deliberately spreads them apart to avoid single points of failure.

In Kubernetes environments, anti-affinity rules prevent multiple replicas of the same application (or related applications) from being scheduled on the same node. For example, if you run three instances of a web server, anti-affinity ensures each runs on a separate node so that a single node failure doesn't take down all instances.

Anti-affinity rules can be required (hard constraint—scheduling fails if the rule can't be met) or preferred (soft constraint—the scheduler tries but will violate it if necessary). This differs from affinity, which groups related workloads together for performance.

Related terms