---
source: https://iinventedlight.com/library/notes/kubernetes-topology-spread-constraints.md
title: "topologySpreadConstraints spread Pods evenly across zones and nodes using maxSkew"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (Kubernetes docs); CC-BY-4.0 (kubernetes/website (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: kubernetes topology spread"
tags: [kubernetes, scheduling, topology-spread, high-availability, zones, maxskew]
client: Librarian
sources:
  - id: S1
    title: "Pod Topology Spread Constraints"
    publisher: Kubernetes docs
    url: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
    accessed: 2026-11-18
    license: "CC-BY-4.0"
  - id: S2
    title: "topology-spread-constraints.md (source page)"
    publisher: kubernetes/website (GitHub)
    url: https://github.com/kubernetes/website/blob/main/content/en/docs/concepts/scheduling-eviction/topology-spread-constraints.md
    accessed: 2026-11-18
    license: "CC-BY-4.0"
---
# 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

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

## Fields

- `maxSkew` describes the degree to which Pods may be unevenly distributed; it is required and must be greater than zero.
- `topologyKey` is a node label key. Nodes with this label and identical values are in the same topology, and each <key, value> pair is a domain.
- `whenUnsatisfiable`: `DoNotSchedule` (default) tells the scheduler not to schedule the Pod; `ScheduleAnyway` still schedules it while prioritizing nodes that minimize the skew.
- `labelSelector` finds the matching Pods that are counted in each topology domain.
- `matchLabelKeys` (optional) lists pod label keys whose values are merged into the `labelSelector`; it cannot be set when `labelSelector` isn't set.
- `minDomains` (optional) indicates a minimum number of eligible domains.

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

- [kubernetes-deployments](https://iinventedlight.com/library/notes/kubernetes-deployments/)
- [kubernetes-labels-selectors](https://iinventedlight.com/library/notes/kubernetes-labels-selectors/)
- [kubernetes-pod-priority-preemption](https://iinventedlight.com/library/notes/kubernetes-pod-priority-preemption/)

## Claims

- id: C1
  claim: maxSkew describes how unevenly Pods may be distributed.
  source: S1
  evidence: "describes the degree to which Pods may be unevenly distributed"

- id: C2
  claim: DoNotSchedule is the default for whenUnsatisfiable.
  source: S2
  evidence: "`DoNotSchedule` (default) tells the scheduler not to schedule it."

- id: C3
  claim: The scheduler tries to balance pods across domains.
  source: S2
  evidence: "The scheduler will try to put a balanced number of pods into each domain."

## Sources

- [S1] Pod Topology Spread Constraints. Kubernetes docs. https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ . License: CC-BY-4.0. Accessed 2026-11-18.

- [S2] topology-spread-constraints.md (source page). kubernetes/website (GitHub). https://github.com/kubernetes/website/blob/main/content/en/docs/concepts/scheduling-eviction/topology-spread-constraints.md . License: CC-BY-4.0. Accessed 2026-11-18.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
