Service Reuses Existing Load Balancer BLB
The Cloud Container Engine (CCE) supports using existing load balancers through the service.beta.kubernetes.io/cce-load-balancer-id: <LoadBalanceId> annotation. You can use this annotation to specify the load balancer instance associated with the cluster service resource. Currently, Load Balancer Service reuse is also supported, allowing multiple services to share the same existing load balancer. This document will explain how to configure it.
Description:
Only CCE LB Controller component versions 1.30.1 and above support BLB reuse. Lower versions do not support reuse. You can upgrade the version in the Component Management > Network of the cluster. For more information, see CCE LB Controller Description.
Use load balancer to configure BLB label behavior
When creating a new BLB for a LoadBalance-type service, CCE will automatically set the cce-created and cce-resource-name labels for the corresponding BLB, with the label contents as follows:
cce-created: <ClusterID>/Service/UID/<Service UID>indicates that the BLB is created by CCE, and the Service will delete the corresponding resources by default upon destruction.cce-resource-name: <ClusterID./Service/UID/<Service UID>indicates that the BLB is already used by the corresponding service in the cluster.
When creating a Load Balancer-type service using an existing BLB, CCE will automatically set the cce-resource-name label for the corresponding BLB. The label content and function vary across CCE LB Controller component versions:
- For CCE LB Controller component versions 1.30.1 and above, the label is
cce-resource-name: <ClusterID>, which is used to identify that it has been used by the cluster and supports reuse by other services under the same cluster. When deleting the service, only the corresponding listener and target group in the BLB will be deleted. - For CCE LB Controller component versions below 1.30.1, the label is
cce-resource-name: <ClusterID>/Service/UID/<Service UID>, which is used to identify that it has been used by the corresponding service in the cluster and does not support reuse by other services under the same cluster.
Note:
Do not modify or delete the CCE-configured labels
cce-createdandcce-resource-name, as this may cause resource leaks.
Usage restrictions
- Only the reuse of existing application BLBs is supported.
- The reused BLB must be located in the same VPC as the cluster.
- The reuse of CCE-auto-created BLB instances is not allowed.
- When multiple services share a BLB, the service ports must not conflict.
- Cross-cluster reuse of BLBs is not supported.
Service example
1apiVersion: v1
2kind: Service
3metadata:
4 name: service-example
5 annotations:
6 prometheus.io/scrape: "true"
7 service.beta.kubernetes.io/cce-load-balancer-id: lb-xxxxxxxx #Specify an existing application BLB instance
8spec:
9 selector:
10 app: nginx
11 type: LoadBalancer
12 externalTrafficPolicy: Cluster# Default value
13 sessionAffinity: None
14 ports:
15 - name: nginx
16 protocol: TCP
17 port: 80
18 targetPort: 80
