Reputation: 21
I am trying to load balance EKS cluster pods according to Availability Zones. I have configured "topologySpreadConstraints" in deployment for pod scale-up which works fine
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
But during scale-down, it removes pods randomly and eventually keeps the cluster unbalanced across AZs.
Example: I have a service "test" running with 6 pods in 3 AZs (AZ-a, AZ-b, AZ-c) According to the above configuration when I scale up to 9 following happens as expected:
Initial -> AZ-a=2, AZ-b=2, AZ-c=2 After scale up -> AZ-a=3, AZ-b=3, AZ-c=3
But when it scales down to 6 pods due to HPA configuration it goes into an unbalanced state After scale down -> AZ-a=3, AZ-b=2, AZ-c=1
HPA configuration is as below
spec:
maxReplicas: 12
minReplicas: 6
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: test
targetCPUUtilizationPercentage: 50
How can we mention either in HPA or deployment to scale down according to AZ again so that the scaled-down version is balanced as well?
Upvotes: 2
Views: 455