← All notes

topologySpreadConstraints spread Pods evenly across zones and nodes using maxSkew

Answer: Add spec.topologySpreadConstraints with maxSkew, a topologyKey such as topology.kubernetes.io/zone, whenUnsatisfiable, and a labelSelector matching the workload's Pods. The scheduler will try to put a balanced number of pods into each domain.

Example

spec:
  topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: web

Fields

There can only be one constraint for a given topologyKey and whenUnsatisfiable value.

Why use it

With only two Pods, you'd prefer not to have both run on the same node, because a single node failure would take the workload offline. As you scale up, you may prefer a similar number of replicas scheduled into each infrastructure zone, to avoid higher latency and network costs between zones.

Defaults

If you configure no cluster-level default constraints, kube-scheduler acts as if you specified maxSkew: 3 on kubernetes.io/hostname and maxSkew: 5 on topology.kubernetes.io/zone, both with ScheduleAnyway. Cluster defaults apply only to Pods that define no constraints and belong to a Service, ReplicaSet, StatefulSet or ReplicationController.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Pod Topology Spread Constraints; kubernetes/website (GitHub), topology-spread-constraints.md (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Pod Topology Spread Constraints; kubernetes/website (GitHub), topology-spread-constraints.md (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.

Cite this

Permanent ID: iil:note:5kv5xjgv

iinventedlight. 2026. "topologySpreadConstraints spread Pods evenly across zones and nodes using maxSkew." iinventedlight Library, iil:note:5kv5xjgv, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-topology-spread-constraints/. License: CC-BY-4.0.

@misc{iil_note_5kv5xjgv,
  author = {{iinventedlight}},
  title = {{topologySpreadConstraints spread Pods evenly across zones and nodes using maxSkew}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/kubernetes-topology-spread-constraints/},
  note = {Permanent ID iil:note:5kv5xjgv. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-topology-spread-constraints.md.