Kubernetes Pod Topology Spread Constraints are scheduling rules that tell Kubernetes to distribute matching pods across topology domains, such as availability zones, nodes, or racks. In practical terms, they help you avoid placing too many replicas of the same workload in one failure domain.
Topology spread constraints reduce placement skew. Instead of letting the scheduler pack replicas wherever resources are available, you can ask it to keep pods balanced across a chosen topology.
Common topology domains include:
kubernetes.io/hostnametopology.kubernetes.io/zonetopology.kubernetes.io/regionrack or node-poolThis is useful for highly available services, batch workers, ingress controllers, and stateful applications where replica placement affects reliability.
You define topology spread constraints in a pod spec, usually inside a Deployment, StatefulSet, Job, or ReplicaSet template. The Kubernetes scheduler then compares how many matching pods already run in each topology domain and places new pods according to your rule.
The main fields are:
topologyKey: the node label that defines the domain, such as topology.kubernetes.io/zone.maxSkew: the maximum allowed difference in matching pod counts between domains.whenUnsatisfiable: what Kubernetes should do if the rule cannot be met. Use DoNotSchedule for strict placement or ScheduleAnyway for best-effort placement.labelSelector: which pods should be counted when calculating skew.minDomains: the minimum number of eligible domains required before Kubernetes applies the skew calculation.Suppose you run a Deployment with 6 replicas across 3 availability zones. With topologyKey: topology.kubernetes.io/zone and maxSkew: 1, Kubernetes tries to keep the pods close to 2 per zone.
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: checkout-api
If one zone already has 3 matching pods and another has 1, the scheduler will prefer the less-populated zone. If DoNotSchedule is set and no valid node can satisfy the rule, the pod stays Pending.
Topology spread constraints and pod anti-affinity can both keep pods apart, but they work differently.
For many modern Kubernetes workloads, topology spread constraints are easier to reason about when you want even distribution rather than absolute separation.
Topology spread constraints depend on accurate node labels. Managed Kubernetes services usually apply zone and region labels automatically, but custom topology labels must be maintained by your platform team.
If you manage workloads with infrastructure as code, define these constraints in your Kubernetes manifests or templates. For example, teams that deploy Kubernetes resources using Terraform can include topology spread rules in the rendered Deployment spec.
When deploying applications on Amazon EKS, the same Kubernetes scheduling behavior applies. For example, a workload like Apache Airflow on AWS Elastic Kubernetes Service may use topology spread constraints to keep schedulers, web servers, or workers distributed across nodes or zones.
Use pod topology spread constraints when replica placement affects uptime, maintenance safety, or resource balance. Start with zone-level spreading for critical services, then add node-level spreading where needed.
A practical default for many stateless Deployments is:
topologyKey: topology.kubernetes.io/zonemaxSkew: 1whenUnsatisfiable: ScheduleAnyway for flexible placement, or DoNotSchedule for stricter availability requirementsChoose strict rules carefully. If your cluster has only one eligible zone, limited capacity, or restrictive taints and node selectors, strict topology spread constraints can block scheduling.