mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
GCE load balancer: Stop managing instance groups for internal load balancer if rbs alpha feature gate enable
use multiple instance groups if present
This commit is contained in:
parent
3f6793de48
commit
f3e8c3b30d
@ -23,6 +23,10 @@ const (
|
|||||||
// AlphaFeatureILBSubsets allows InternalLoadBalancer services to include a subset
|
// AlphaFeatureILBSubsets allows InternalLoadBalancer services to include a subset
|
||||||
// of cluster nodes as backends instead of all nodes.
|
// of cluster nodes as backends instead of all nodes.
|
||||||
AlphaFeatureILBSubsets = "ILBSubsets"
|
AlphaFeatureILBSubsets = "ILBSubsets"
|
||||||
|
|
||||||
|
// AlphaFeatureNetLBRbs enabled L4 Regional Backend Services and
|
||||||
|
// disables instance group management in service controller
|
||||||
|
AlphaFeatureNetLBRbs = "NetLB_RBS"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AlphaFeatureGate contains a mapping of alpha features to whether they are enabled
|
// AlphaFeatureGate contains a mapping of alpha features to whether they are enabled
|
||||||
|
@ -50,6 +50,16 @@ func (g *Cloud) DeleteInstanceGroup(name string, zone string) error {
|
|||||||
return mc.Observe(g.c.InstanceGroups().Delete(ctx, meta.ZonalKey(name, zone)))
|
return mc.Observe(g.c.InstanceGroups().Delete(ctx, meta.ZonalKey(name, zone)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FilterInstanceGroupsByName lists all InstanceGroups in the project and
|
||||||
|
// zone that match the name regexp.
|
||||||
|
func (g *Cloud) FilterInstanceGroupsByName(name, zone string) ([]*compute.InstanceGroup, error) {
|
||||||
|
ctx, cancel := cloud.ContextWithCallTimeout()
|
||||||
|
defer cancel()
|
||||||
|
mc := newInstanceGroupMetricContext("list", zone)
|
||||||
|
v, err := g.c.InstanceGroups().List(ctx, zone, filter.Regexp("name", name))
|
||||||
|
return v, mc.Observe(err)
|
||||||
|
}
|
||||||
|
|
||||||
// ListInstanceGroups lists all InstanceGroups in the project and
|
// ListInstanceGroups lists all InstanceGroups in the project and
|
||||||
// zone.
|
// zone.
|
||||||
func (g *Cloud) ListInstanceGroups(zone string) ([]*compute.InstanceGroup, error) {
|
func (g *Cloud) ListInstanceGroups(zone string) ([]*compute.InstanceGroup, error) {
|
||||||
|
@ -625,11 +625,21 @@ func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]s
|
|||||||
klog.V(2).Infof("ensureInternalInstanceGroups(%v): %d nodes over %d zones in region %v", name, len(nodes), len(zonedNodes), g.region)
|
klog.V(2).Infof("ensureInternalInstanceGroups(%v): %d nodes over %d zones in region %v", name, len(nodes), len(zonedNodes), g.region)
|
||||||
var igLinks []string
|
var igLinks []string
|
||||||
for zone, nodes := range zonedNodes {
|
for zone, nodes := range zonedNodes {
|
||||||
igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes)
|
if g.AlphaFeatureGate.Enabled(AlphaFeatureNetLBRbs) {
|
||||||
if err != nil {
|
igs, err := g.FilterInstanceGroupsByName(name, zone)
|
||||||
return []string{}, err
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
for _, ig := range igs {
|
||||||
|
igLinks = append(igLinks, ig.SelfLink)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
igLinks = append(igLinks, igLink)
|
||||||
}
|
}
|
||||||
igLinks = append(igLinks, igLink)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return igLinks, nil
|
return igLinks, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user