Pod Anti-Affinity Calculator
Calculate the maximum replicas that can be spread across availability zones under a podAntiAffinity rule, one per node per zone.
Inputs
Usually 1 with a strict same-node anti-affinity rule.
Max Replicas Under Anti-Affinity
15pods
Desired Replicas Fit
true
Replicas per Zone (Even Spread)
4pods
Capacity Lost per Zone Failure
33.3%
Step by step
Max replicas = zones × nodes per zone × max per node
3 × 5 × 1
= 15
Even spread per zone
ceil(12 ÷ 3)
= 4
How it works
podAntiAffinity (or the more flexible topologySpreadConstraints) prevents replicas from stacking on the same node or zone, trading some scheduling flexibility for resilience — a single node or zone failure can only take out a bounded fraction of replicas. The ceiling on replicas is zones × nodes-per-zone × max-allowed-per-node; requesting more replicas than that ceiling leaves excess pods permanently Pending.
Formula
maxReplicas = zones × nodesPerZone × maxPerNode
- Z
- Number of availability zones
- N_z
- Nodes per zone
- P_n
- Max replicas allowed per node
- R_{max}
- Maximum replicas under anti-affinity constraint
Frequently Asked Questions
What's the difference between podAntiAffinity and topologySpreadConstraints?
podAntiAffinity is boolean (avoid/prefer co-location) and gets computationally expensive at scale. topologySpreadConstraints explicitly controls the maximum skew between topology domains (e.g. max 1 pod difference between zones) and is the newer, more scalable, more precise mechanism for even spreading.
What happens if desired replicas exceed the anti-affinity ceiling?
With a hard (required) anti-affinity rule, excess pods beyond the ceiling stay Pending indefinitely since no eligible node/zone slot remains — switch to a soft (preferred) rule or add nodes/zones to raise the ceiling.
Why does spreading across zones matter for availability?
Cloud availability zones fail independently — spreading replicas evenly means a single zone outage removes at most 1/N of capacity (matching zoneFailureImpactPercent) rather than potentially all of it if replicas happened to cluster in one zone.