Home

antiaffinity

Antiaffinity is a scheduling constraint in distributed systems that prevents certain entities from sharing the same resource, such as a node, host, or zone. It is used to improve fault tolerance, isolation, and resource distribution by avoiding co-location of related workloads.

In container orchestration platforms like Kubernetes, pod anti-affinity enables label-based rules that restrict where pods may

Common use cases include spreading replicas of a service across nodes or zones to reduce the risk

Limitations include increased scheduling complexity and the possibility of unschedulable pods if capacity is insufficient. Rigid

Across platforms, anti-affinity is a general concept with platform-specific implementations, notably in Kubernetes through PodAntiAffinity.

be
scheduled
relative
to
other
pods.
These
rules
can
be
hard
or
soft:
strict
constraints
use
components
like
RequiredDuringSchedulingIgnoredDuringExecution,
while
softer
preferences
use
PreferredDuringSchedulingIgnoredDuringExecution.
A
topologyKey
defines
the
dimension
over
which
to
spread
pods
(for
example,
kubernetes.io/hostname
for
node-level
distribution
or
topology.kubernetes.io/zone
for
zone-level
distribution).
Labels
on
the
target
pods
determine
which
pods
to
avoid
co-locating
with.
of
a
single
point
of
failure,
and
avoiding
contention
for
shared
resources
on
a
node.
Anti-affinity
can
also
help
satisfy
policy
or
licensing
requirements
that
limit
co-location
of
certain
workloads.
hard
anti-affinity
rules
can
reduce
utilization;
soft
preferences
guide
the
scheduler
while
allowing
co-location
if
necessary.
Anti-affinity
should
be
considered
alongside
affinity
rules
and
resource
requests
to
avoid
conflicts.