Kubernetes topology spread: account for missing zones
Carry a missing zone through the placement calculation before adding nodes or weakening the recovery policy.
Quick answer
Kubernetes topology spread can keep a Pod Pending even when surviving nodes have spare resources. Check the eligible domains, matching Pod counts and hard placement constraints together. If a zone disappears, decide whether to restore its capacity or accept a documented reduction in failure isolation before changing the spread policy.
On this page
Kubernetes topology spread can keep a Pod Pending even when surviving nodes have spare resources. Check the eligible domains, matching Pod counts and hard placement constraints together. If a zone disappears, decide whether to restore its capacity or accept a documented reduction in failure isolation before changing the spread policy. [1]
Why can spare capacity still leave a Pod Pending?#
A hard spread constraint can exclude every node that has enough resources. The scheduler is trying to satisfy the Pod's placement contract, rather than simply find an empty machine. Resource requests are another independent condition: adding capacity helps only when that capacity is in a location the Pod can use. [1][6]
During a zone failure, spare CPU can distract from the missing placement domain. An operator sees idle CPU, replacement Pods stay Pending, and increasing the maximum node count looks reasonable. But a node added to the same surviving zone may leave the topology calculation unchanged. Before buying capacity or loosening rules, write down which missing condition the proposed node would satisfy.
Start with the actual pending Pod, not just the Deployment source in Git. Admission controllers, chart values and an older ReplicaSet can make those specifications differ. Preserve its scheduler events and assigned labels. The Kubernetes debugging guide directs investigators to the scheduler messages in kubectl describe; those messages are evidence to follow, not a complete explanation of the application’s recovery policy. [5]
# Read-only examples. Substitute the namespace and actual pending Pod.
kubectl -n payments describe pod payment-api-pending
kubectl -n payments get pod payment-api-pending -o yaml
kubectl get nodes -L topology.kubernetes.io/zone,pool
kubectl -n payments get pods -l app=payment-api -o wideSave the Pod specification, scheduler events and node inventory together. A list of node labels from after a repair cannot explain the counts that blocked the original Pod. Save the observation time and revision with the incident record, then repeat the inventory after each deliberate change.
Count the domains in a fictional zone loss#
Scenario: a stateless payment API wants six replicas across zones A, B and C. Before the incident, each zone has two matching replicas. The nodes in C are now absent from the cluster, and its lost replicas have been removed. Four ready replicas remain, split evenly across A and B. This is an arithmetic example, not a reported production incident.
The relevant Deployment Pod-template fragment is:
# Fragment under a Deployment's spec; retain its existing selector,
# containers, resource requests and other placement requirements.
template:
metadata:
labels:
app: payment-api
spec:
nodeSelector:
pool: serving
topologySpreadConstraints:
- topologyKey: topology.kubernetes.io/zone
maxSkew: 1
minDomains: 3
whenUnsatisfiable: DoNotSchedule
nodeAffinityPolicy: Honor
nodeTaintsPolicy: Honor
labelSelector:
matchLabels:
app: payment-apiCheck that the cluster supports the fields in the fragment before using it. The current topology reference describes inclusion policies and the availability history of minDomains; an accepted YAML file from another cluster is insufficient compatibility evidence. Use the cluster’s API explanation and server validation in a rehearsal environment. [1]
Scenario: only A and B are eligible domains now. Because there are fewer eligible domains than the configured minimum, the spread calculation uses a global minimum of zero. Putting an incoming replacement into A would give A three matching replicas. Its prospective skew is three minus zero, which exceeds the permitted skew of one. B fails the same calculation. [1]
Scenario: adding another empty node in A supplies resources but does not add a domain. Restoring an eligible node in C supplies a previously missing domain with zero matching replicas. Placing a replacement there gives a prospective count of one against the zero minimum, which fits this spread rule. Other scheduling conditions must still pass. [1]
The example reveals the decision hidden inside the configuration. The hard rule currently values the specified spread over restoring the desired replica count on the remaining zones. That may be exactly the intended resilience policy. It may also be an unintended obstacle during an extended outage. Neither conclusion follows from a Pending status alone.
Which nodes belong in the calculation?#
Determine eligibility before doing arithmetic. Node labels, required affinity and the configured inclusion policies define which topology domains enter the spread calculation. A zone displayed in a cloud console does not establish that the scheduler currently has a usable node in that zone. [1][2]
Read the inclusion policies explicitly. This example honors both node affinity and taints for topology counting. Tolerations still only permit consideration of a tainted node; they do not guarantee placement. Do not add a broad toleration to repair a count without checking whether it admits the workload onto maintenance, dedicated or otherwise unsuitable nodes. [3]
Also inspect the matching Pod set. The spread selector counts matching Pods in the namespace, so a broad application label can include both old and new rollout revisions. That may be intentional: the application cares about all serving replicas. If revision isolation is required, establish the version-specific selector behavior deliberately. Avoid changing the selector merely to make an inconvenient count disappear. [1]
For the fictional payment API, the operator’s evidence should answer these questions:
- Which existing nodes have the required pool and zone labels?
- Which of those nodes can accept this Pod’s requests and other constraints?
- Which domains participate under the inclusion policies?
- Which Pods match the spread selector, including rollout revisions?
- Is another hard rule excluding the nodes favored by spread?
A second constraint can create an empty intersection. For example, zone spread may favor a node whose hostname spread or required affinity disallows it. A diagnosis that evaluates each rule independently can mistakenly conclude that every rule has an available candidate. The useful result is a node that satisfies their combined requirements. [1][2]
Do not relabel an existing node as the missing zone. The label represents a failure domain. Changing its spelling cannot move its power, network or storage dependencies, and would make the placement record misrepresent the resilience the application actually has.
How should you change the recovery policy?#
Choose between restoring the missing placement capability and approving a degraded placement policy. These are operational alternatives with different risks. Increasing maxSkew, lowering minDomains and changing to a soft constraint alter different parts of the contract; treat each as a named change rather than an interchangeable scheduling fix. [1]
| Choice | What it addresses | Evidence required before use |
|---|---|---|
| Restore the absent domain | Retains the intended hard spread | Eligible node, matching labels, resources and working dependencies |
| Lower the minimum domain requirement | Permits the agreed smaller domain set | Application owner accepts reduced failure isolation |
| Prefer spread with ScheduleAnyway | Makes spread a preference | Other constraints still protect the workload; concentrated placement is acceptable |
| Add nodes in a surviving domain | Relieves resource pressure there | A candidate node already passes the topology rule |
Scenario: if the incident owner accepts operation across A and B, changing the minimum domain requirement to two permits the replacement sequence in this simplified case. A placement into A produces counts of three and two, with prospective skew one. A subsequent placement into B can restore an even split of three and three. This prediction assumes the node inventory and matching Pod set remain as described. [1]
A soft rule is a broader decision. ScheduleAnyway prioritizes better spread without making this spread constraint a hard rejection. The minDomains field belongs with DoNotSchedule; do not retain an incompatible field combination while switching policies. Review the resulting Pod template and actual created Pods, rather than assuming a chart value changed the intended field. [1]
The infrastructure branch also needs evidence. Node autoscalers consider Pod scheduling constraints together with their own provisioning constraints. A node group’s zone coverage, limits or provider capacity can prevent the needed node from appearing. Inspect the autoscaler’s decision and the proposed node’s properties. Repeatedly raising a general limit does not prove that the missing domain is provisionable. [4]
Temporarily lower desired replicas only if that reflects a service-capacity decision. It can quiet a Pending alert while leaving the application below its recovery objective. Keep the original desired count visible in the incident record so a temporary acceptance cannot quietly become the new normal.
What proves the service is recovered?#
Recovery requires successful placement and working application capacity. Verify that replacement Pods are assigned to suitable nodes, become ready and serve the expected workload. A topology calculation establishes eligibility under one rule; it does not test image access, mounted data, network paths or the application’s readiness behavior.
Follow the created Pod through those stages. If the scheduling event clears but startup fails, preserve the successful placement evidence and investigate the new boundary. If it becomes ready but receives no traffic, follow the Service endpoint investigation. If no candidate can fit its requests, use the per-node CPU request diagnosis.
For a rehearsal, reproduce the missing-domain case in an isolated cluster with known labels. Record a blocked placement before the change and a permitted placement after it. Change the affinity or taint on the only useful candidate to verify the adverse branch. Repeat during a rollout so the matching Pod population is visible. The arithmetic shown here is a model; it does not substitute for running that scheduler experiment.
Check both planned outcomes. Under the original hard policy, failure to place can be correct. Under an approved degraded policy, placement on surviving domains can be correct. The acceptance record should say which outcome is required, otherwise the test merely rewards whichever behavior the configuration happened to produce.
Record the degraded placement decision#
Write the restoration decision before changing the policy. If a missing domain returns, decide whether the service should immediately resume the original constraint, wait for a controlled rollout, or keep the degraded policy while another dependency is repaired. Put an owner beside that choice. An alert closing because no Pod remains Pending is too narrow a trigger for a resilience decision.
Keep application capacity and isolation in separate acceptance fields. A service can meet its immediate traffic requirement while carrying a larger exposure to the next failure. Conversely, a perfectly spread but underprovisioned service can still miss its traffic objective. The incident owner needs both observations to decide whether the temporary state is acceptable, and a rehearsal should make it possible to observe either one failing independently.
Save the observed domain set, matching counts, active constraints, chosen policy, owner and restoration trigger together. Include the expected post-change placement and the evidence that the service can handle traffic. This is Dopstack’s suggested incident record, not a Kubernetes requirement.
Define when to restore the original policy: topology spread primarily influences new placement. Reintroducing a zone or tightening the policy does not itself promise that existing Pods are redistributed into an ideal layout. Plan any later rollout or rebalancing deliberately, with the service’s disruption and capacity limits in view. [1]
Keep the temporary policy in the same configuration workflow as the permanent one. An emergency patch that is absent from the declared deployment may be reversed by reconciliation; an emergency value that is never removed may survive long after the zone returns. In either case, the owner needs a precise configuration diff and a clear next action.
What else should you verify?#
- Does minDomains guarantee that every zone has a ready replica?
- No. It affects the global minimum used by a hard spread calculation. It does not provision nodes, make Pods ready or continuously rebalance an application. Verify available domains, actual placement and service readiness separately. [1]
- Can more nodes in a surviving zone fix the blockage?
- They can relieve resource pressure if that domain already satisfies the placement rules. They do not create a missing topology domain. Identify the rejection first, then check whether the proposed node changes that condition. [1][4]
- Why count old rollout Pods?
- A broad spread selector can intentionally include old and new replicas that share the application label. Review that matching population and the deployed version’s selector features. Changing the counted set changes the resilience policy, even if scheduling becomes easier. [1]
- Will restoring the original rule rebalance existing Pods?
- Do not assume that it will. Spread constraints guide placement, and removal can leave an imbalanced distribution. Plan and verify any subsequent rollout or rebalancing with the application’s disruption and capacity limits in view. [1]