Skip to content

Commit f76728f

Browse files
authored
Merge pull request kubernetes#90048 from wojtek-t/automated-cherry-pick-of-#89902-upstream-release-1.18
Automated cherry pick of kubernetes#89902 upstream release 1.18
2 parents c48ba09 + 6fb6533 commit f76728f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_internal.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const (
4545
ILBFinalizerV1 = "gke.networking.io/l4-ilb-v1"
4646
// ILBFinalizerV2 is the finalizer used by newer controllers that implement Internal LoadBalancer services.
4747
ILBFinalizerV2 = "gke.networking.io/l4-ilb-v2"
48+
// maxInstancesPerInstanceGroup defines maximum number of VMs per InstanceGroup.
49+
maxInstancesPerInstanceGroup = 1000
4850
)
4951

5052
func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
@@ -512,6 +514,17 @@ func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.Node)
512514
kubeNodes.Insert(n.Name)
513515
}
514516

517+
// Individual InstanceGroup has a limit for 1000 instances in it.
518+
// As a result, it's not possible to add more to it.
519+
// Given that the long-term fix (AlphaFeatureILBSubsets) is already in-progress,
520+
// to stop the bleeding we now simply cut down the contents to first 1000
521+
// instances in the alphabetical order. Since there is a limitation for
522+
// 250 backend VMs for ILB, this isn't making things worse.
523+
if len(kubeNodes) > maxInstancesPerInstanceGroup {
524+
klog.Warningf("Limiting number of VMs for InstanceGroup %s to %d", name, maxInstancesPerInstanceGroup)
525+
kubeNodes = sets.NewString(kubeNodes.List()[:maxInstancesPerInstanceGroup]...)
526+
}
527+
515528
gceNodes := sets.NewString()
516529
if ig == nil {
517530
klog.V(2).Infof("ensureInternalInstanceGroup(%v, %v): creating instance group", name, zone)

staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_internal_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,29 @@ func TestEnsureInternalBackendServiceGroups(t *testing.T) {
148148
}
149149
}
150150

151+
func TestEnsureInternalInstanceGroupsLimit(t *testing.T) {
152+
t.Parallel()
153+
154+
vals := DefaultTestClusterValues()
155+
nodeNames := []string{}
156+
for i := 0; i < maxInstancesPerInstanceGroup+5; i++ {
157+
nodeNames = append(nodeNames, fmt.Sprintf("node-%d", i))
158+
}
159+
160+
gce, err := fakeGCECloud(vals)
161+
require.NoError(t, err)
162+
163+
nodes, err := createAndInsertNodes(gce, nodeNames, vals.ZoneName)
164+
require.NoError(t, err)
165+
igName := makeInstanceGroupName(vals.ClusterID)
166+
_, err = gce.ensureInternalInstanceGroups(igName, nodes)
167+
require.NoError(t, err)
168+
169+
instances, err := gce.ListInstancesInInstanceGroup(igName, vals.ZoneName, allInstances)
170+
require.NoError(t, err)
171+
assert.Equal(t, maxInstancesPerInstanceGroup, len(instances))
172+
}
173+
151174
func TestEnsureInternalLoadBalancer(t *testing.T) {
152175
t.Parallel()
153176

0 commit comments

Comments
 (0)