☸️ Fix Topology Spread Constraints Leaving Pods Pending
A topologySpreadConstraint with whenUnsatisfiable: DoNotSchedule tells the scheduler to refuse placement entirely rather than accept an uneven spread, and on a cluster with fewer available zones or nodes than the constraint’s maxSkew math requires — common right after a node pool scales down, or in a cluster with an odd number of zones — the scheduler has no valid placement that satisfies the constraint, so pods sit in Pending indefinitely with no obvious resource shortage to explain why.
🔎 The Problem
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels: { app: checkout }
# kubectl get pods: 2 Pending
# kubectl describe pod: "0/6 nodes are available: 3 node(s) didn't
# match pod topology spread constraints, 3 node(s) had taints..."
# Cluster currently has only 2 usable zones, not the 3 the deployment expects
✅ Fix: Match the Constraint to What the Cluster Can Actually Offer
- Switch
whenUnsatisfiabletoScheduleAnywayfor workloads where an even spread is a preference rather than a hard requirement, so the scheduler does its best instead of refusing to place the pod at all. - If an even spread truly is mandatory, either raise
maxSkewto a value the current zone count can satisfy, or fix the underlying zone/node shortage (restore the scaled-down node pool) before relying on the stricter constraint again. - Add a
kubectl get nodes -L topology.kubernetes.io/zonecheck to your deployment pipeline so a DoNotSchedule constraint’s assumptions about zone count get validated before it ever reaches production.
DoNotSchedule means exactly what it says — if the cluster can’t satisfy the spread you asked for, the pod simply doesn’t get a node.




