Skip to content

Commit 4255617

Browse files
add business-name to isolate ELB instances in multiple clusters (#240)
1 parent ec41ae1 commit 4255617

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

docs/huawei-cloud-controller-manager-configuration.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Huawei Cloud Controller Manager Configurations
1+
_# Huawei Cloud Controller Manager Configurations
22

33
There are 2 sets of configurations, as follows:
44

@@ -227,3 +227,10 @@ The following arguments are supported:
227227

228228
* `disable-create-security-group` Optional. Disable automatic creation of security groups for ELB health checks.
229229
Valid values are `'true'` and `'false'`. The default is `'false'`.
230+
231+
* `business-name` Optional. Business name or business identifier used to compose the name of the Huawei Cloud ELB instance.
232+
To prevent the creation of ELB instances with the same name in Huawei Cloud when using the same tenant account in multiple K8s clusters,
233+
which may ultimately cause CCM to malfunction.
234+
For example, `business-name: order-pass`, kubernetes loadbalancer service namespace/name: `default/order-service`,
235+
then the name of the ELB instance is: `k8s_service_order-pass_default_order-service`.
236+
> Changing this will create new ELB instances, the old ELB instances will not be deleted and no longer maintained.

pkg/cloudprovider/huaweicloud/dedicatedloadbalancer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ func (d *DedicatedLoadBalancer) getLoadBalancerInstance(ctx context.Context, clu
104104

105105
func (d *DedicatedLoadBalancer) GetLoadBalancerName(_ context.Context, clusterName string, service *v1.Service) string {
106106
klog.Infof("GetLoadBalancerName: called with service %s/%s", service.Namespace, service.Name)
107+
if d.loadbalancerOpts.BusinessName != "" {
108+
clusterName = d.loadbalancerOpts.BusinessName
109+
}
107110
name := fmt.Sprintf("k8s_service_%s_%s_%s", clusterName, service.Namespace, service.Name)
108111
return utils.CutString(name, defaultMaxNameLength)
109112
}

pkg/cloudprovider/huaweicloud/sharedloadbalancer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func (l *SharedLoadBalancer) getLoadBalancerInstance(ctx context.Context, cluste
114114
// *v1.Service parameter as read-only and not modify it.
115115
func (l *SharedLoadBalancer) GetLoadBalancerName(_ context.Context, clusterName string, service *v1.Service) string {
116116
klog.Infof("GetLoadBalancerName: called with service %s/%s", service.Namespace, service.Name)
117+
if l.loadbalancerOpts.BusinessName != "" {
118+
clusterName = l.loadbalancerOpts.BusinessName
119+
}
117120
name := fmt.Sprintf("k8s_service_%s_%s_%s", clusterName, service.Namespace, service.Name)
118121
return utils.CutString(name, defaultMaxNameLength)
119122
}

pkg/config/loadbalancerconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type LoadBalancerOptions struct {
6969

7070
DisableCreateSecurityGroup bool `json:"disable-create-security-group"`
7171
LoadBalancerClass string `json:"loadbalancer-class"`
72+
BusinessName string `json:"business-name"`
7273
}
7374

7475
type HealthCheckOption struct {

0 commit comments

Comments
 (0)