Tencent Kubernetes Engine (TKE) supports existing Cloud Load Balancers (CLBs) by using the
service.kubernetes.io/tke-existed-lbid: <LoadBalanceId> annotation. You can use this annotation to specify a CLB instance to be associated with cluster service resources. TKE also provides the feature of CLB sharing by multiple services, which allows you to specify multiple services to share an existing CLB. To configure this feature, refer to the sample configuration in this document.
tke-createdBy-flag = yesis configured for all CLBs created by services. When a service is terminated, the corresponding resources are deleted. If an existing CLB is used, this tag is not configured, and the corresponding resources are not deleted when the service is terminated.
tke-clusterId =is configured for all services. If the ClusterId is correct, the tag is deleted when the service is terminated.
tke-clusterId: cls-xxxxis retained for the CLB, and can only be cleared manually.
apiVersion: v1 kind: Service metadata: annotations: service.kubernetes.io/tke-existed-lbid: lb-6swtxxxx name: nginx-service spec: ports: - name: 80-80-no port: 80 protocol: TCP targetPort: 80 selector: app: nginx type: LoadBalancer
service.kubernetes.io/tke-existed-lbid: lb-6swtxxxxindicates that the service uses an existing CLB for configuration.
- Note that the service type must be set to
When the Service Controller component manages CLB lifecycles, it only supports the purchase of pay-as-you-go CLBs. When you need to use a CLB for a long term, the monthly subscription mode is more cost-effective. In such cases, you can purchase and manage CLBs independently, use annotations to control the use of existing CLBs by services, and remove CLB lifecycle management from the Service Controller component.
According to the official Kubernetes restrictions in service design, when multiple port protocols are opened under the same service, these protocols must be the same. In many game scenarios, users need to simultaneously open the TCP and UDP services in the same port. Tencent CLBs support simultaneous listening on UDP and TCP over the same port. This demand can be met through CLB sharing by multiple services.
For example, in the following service configuration,
game-service is described as two service resources. The descriptions are basically the same except for the protocols for listening. Both services specify the use of an existing CLB
lb-6swtxxxx through annotations. By applying the resources to a cluster through kubectl, multiple protocols can be exposed over the same CLB port.
apiVersion: v1 kind: Service metadata: annotations: service.kubernetes.io/tke-existed-lbid: lb-6swtxxxx name: game-service-a spec: ports: - name: 80-80-tcp port: 80 protocol: TCP targetPort: 80 selector: app: game type: LoadBalancer ------------------------------------------------ apiVersion: v1 kind: Service metadata: annotations: service.kubernetes.io/tke-existed-lbid: lb-6swtxxxx name: game-service-b spec: ports: - name: 80-80-udp port: 80 protocol: UCP targetPort: 80 selector: app: game type: LoadBalancer