Sitelet https://github.com/kubernetes/kops/pull/18544/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/kops/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ func TestHA(t *testing.T) {
func TestHighAvailabilityGCE(t *testing.T) {
newIntegrationTest("ha-gce.example.com", "ha_gce").withZones(3).
withAddons(
clusterAutoscalerAddon,
dnsControllerAddon,
gcpCCMAddon,
gcpPDCSIAddon,
Expand Down
52 changes: 32 additions & 20 deletions pkg/model/gcemodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,29 +288,41 @@ func (b *AutoscalingGroupModelBuilder) splitToZones(ig *kops.InstanceGroup) (map
// 1) no support in terraform
// 2) we can't steer to specific zones AFAICT, only to all zones in the region

targetSizes := make([]int, len(zones))
totalSize := 0
for i := range zones {
targetSizes[i] = minSize / len(zones)
totalSize += targetSizes[i]
}
i := 0
for totalSize < minSize {
targetSizes[i]++
totalSize++

i++
if i >= len(targetSizes) {
i = 0
}
}
return SplitCountAcrossZones(minSize, zones), nil
}
}

instanceCountByZone := make(map[string]int)
for i, zone := range zones {
instanceCountByZone[zone] = targetSizes[i]
// SplitCountAcrossZones distributes count across zones as evenly as possible,
// assigning the remainder to zones in the order given. Both the target sizes
// of the per-zone InstanceGroupManagers and the min/max sizes registered with
// cluster-autoscaler are derived from this split, so they stay consistent.
func SplitCountAcrossZones(count int, zones []string) map[string]int {
if len(zones) == 0 {
return map[string]int{}
}

targetSizes := make([]int, len(zones))
totalSize := 0
for i := range zones {
targetSizes[i] = count / len(zones)
totalSize += targetSizes[i]
}
i := 0
for totalSize < count {
targetSizes[i]++
totalSize++

i++
if i >= len(targetSizes) {
i = 0
}
return instanceCountByZone, nil
}

countByZone := make(map[string]int)
for i, zone := range zones {
countByZone[zone] = targetSizes[i]
}
return countByZone
}

func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ spec:
leaderElection:
leaderElect: true
cloudProvider: gce
clusterAutoscaler:
awsUseStaticInstanceList: false
balanceSimilarNodeGroups: false
emitPerNodegroupMetrics: false
enabled: true
expander: random
ignoreDaemonSetsUtilization: false
image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.32.7
maxNodeProvisionTime: 15m0s
newPodScaleUpDelay: 0s
scaleDownDelayAfterAdd: 10m0s
scaleDownUnneededTime: 10m0s
scaleDownUnreadyTime: 20m0s
scaleDownUtilizationThreshold: "0.5"
skipNodesWithCustomControllerPods: true
skipNodesWithLocalStorage: true
skipNodesWithSystemPods: true
clusterDNSDomain: cluster.local
configBase: memfs://tests/ha-gce.example.com
containerd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ spec:
name: dns-controller.addons.k8s.io
selector:
k8s-addon: dns-controller.addons.k8s.io
- id: k8s-1.15
manifest: cluster-autoscaler.addons.k8s.io/k8s-1.15.yaml
manifestHash: d5520ffa5552a7f2cfc659fa19472299ef8e58d1fbc8117b8c33ade21157cc0f
name: cluster-autoscaler.addons.k8s.io
selector:
k8s-addon: cluster-autoscaler.addons.k8s.io
- id: v1.7.0
manifest: storage-gce.addons.k8s.io/v1.7.0.yaml
manifestHash: 4f73c7d683f04e61d60e90053a6db1fd82272dc0c13790390740f5e207181c77
Expand Down
Loading
Loading