- Newest
- Most votes
- Most comments
Have you ever tried to set up Topology Spread using parameters maxSkew and minDomain, to achieve this balance?
I'm doing some tests on it and achieving exactly this scenario. Look at this:
topologySpreadConstraints:
- maxSkew: 1
minDomains: 3
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: my-app
answered a year ago
The imbalance you're experiencing with Karpenter placing most nodes in Zone B is likely because Karpenter is optimizing for cost and availability rather than zone balance. By default, Karpenter will provision nodes as quickly and cheaply as possible, which may lead to concentration in a single zone if that zone has better pricing or availability for Spot instances.
To achieve better AZ distribution, you have a few options:
- Use Pod Topology Spread Constraints: Even for single-pod applications, you can use topology spread constraints in your pod specifications. This would encourage the Kubernetes scheduler to spread pods across zones, which would in turn cause Karpenter to provision nodes in different zones. For example:
spec: topologySpreadConstraints: - maxSkew: 1 topologyKey: "topology.kubernetes.io/zone" whenUnsatisfiable: ScheduleAnyway labelSelector: matchLabels: app: your-app-label
-
Create Multiple NodePools with Zone Constraints: While you mentioned wanting to avoid this approach, creating separate NodePools for each zone with appropriate capacity limits can help ensure a more balanced distribution. This isn't entirely manual as Karpenter will still handle the scaling within each zone.
-
Adjust Workload Requirements: Your workloads can specify their availability requirements through taints, tolerations, and PodTopologySpread. By defining these requirements, you can influence how Karpenter provisions nodes across zones.
-
Consider Using EKS Auto Mode: Although you mentioned you're not using it, EKS Auto Mode builds upon Karpenter and can help with more balanced zone distribution.
The key insight is that Karpenter is primarily focused on meeting workload requirements efficiently rather than ensuring zone balance. By explicitly defining zone distribution requirements in your workloads, you can guide Karpenter to provision nodes more evenly across zones.
Sources
Kubernetes Data Plane - Amazon EKS
Scale cluster compute with Karpenter and Cluster Autoscaler - Amazon EKS
VPC and Subnet Considerations - Amazon EKS
Community | Run Kubernetes Clusters for Less with Amazon EC2 Spot and Karpenter
answered a year ago
Relevant content
asked a year ago
asked a year ago
asked 3 years ago
- AWS OFFICIALUpdated a year ago

The topology spread constraints seems to be related to the pods spread... https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
Yes, it's true. Reading again, I saw that in this case they had only 1 Pod...so, hard to help without manual intervention. Maybe with some features in the near future, like Manual Node Provisioning (github.com/kubernetes-sigs/karpenter/issues/749), he can achieve something closer to his scenario.