When you set a service type to load balancing, that is, Type=LoadBalancer, the Cloud Controller Manager (CCM) component of Alibaba Cloud Container Service for Kubernetes (ACK) creates or configures a load balancer instance for the service. The instance can be a Classic Load Balancer (CLB) or a Network Load Balancer (NLB). The configuration includes resources such as the instance, listeners, and backend server groups. This topic describes important notes for configuring service load balancing and explains the resource update policies of CCM.
Notes
Which load balancers can be reused?
You can only reuse instances created in the Server Load Balancer (SLB) console. You cannot reuse SLB instances that are automatically created by cloud-controller-manager or other SLB instances that are managed by ACK, such as the load balancer used by the API Server.
To reuse a private network SLB instance in an ACK cluster, the instance must be in the same virtual private cloud (VPC) as the ACK cluster. Cross-VPC reuse applies only to NLB instances.
The address type of the reused SLB instance must match the access type of the Service. If the Service is for public network access (that is,
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "internet"), the Address Type of the SLB instance must be Public. If the Service is for internal access (that is,service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"), the Address Type of the SLB instance must be Private.Multiple Services cannot use the same listener port on the same SLB instance simultaneously.
When you reuse an existing SLB instance across clusters, ensure that the combination of namespace and Service name is unique for each cluster.
Notes on CCM-managed load balancers
CCM configures load balancing for Services of the
Type=LoadBalancertype, but not for Services of other types.CCM uses a declarative API. It automatically refreshes the load balancer configuration based on the Service configuration under certain conditions. Any configurations that you modify in the SLB console are at risk of being overwritten.
Do not manually delete or modify the
service.k8s.alibaba/resourcesorservice.k8s.alibaba/nlbFinalizer on a Service. Manually changing the Finalizer may prevent CLB or NLB resources from being released correctly.For Cloud Controller Manager v2.5.0 and later, the Classic Load Balancer (CLB) instance option is a whitelist feature available when you create a service in the console. To use this feature, submit a request on the Quota Center platform.
If you change a Service from Type=LoadBalancer to another type (Type!=LoadBalancer), CCM deletes the load balancer configuration. This makes the Service inaccessible through the SLB instance.
Do not manually modify any configuration of an SLB instance created and maintained by ACK in the SLB console. This can cause configuration loss and make the Service inaccessible.
Notes on accessing the external IP of a LoadBalancer service from within a cluster
Depending on the network plugin type, plugin version, and cluster version, when you access the CLB IP of a LoadBalancer Service from within a cluster, the cluster network intercepts the traffic on the node. It then forwards the traffic directly to the backend Service Endpoint.
This process bypasses the external CLB instance. This can cause specific configurations that rely on the CLB instance to fail and can lead to access issues. The main scenarios affected include the following:
externalTrafficPolicyis set toLocal: Traffic might be forwarded to a node that has no backend pods, causing the access to fail.Proxy Protocol is enabled: The backend Service cannot obtain the Proxy Protocol header added by the CLB instance. This causes the protocol handshake to fail.
HTTP/HTTPS listener is used: Operations that rely on the CLB instance, such as TLS termination or adding specific headers such as
X-Forwarded-For, will not take effect.
Therefore, to access a LoadBalancer Service from within the cluster:
Use the Service's in-cluster address. This method is standard and more stable. For inter-service communication within the cluster, use the Service's ClusterIP or its DNS name, such as
<service-name>.<namespace>.svc.cluster.local.If you must use the CLB address, access it through a hostname. Add the
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-hostnameannotation to the Service. Then, use the configured domain name instead of the IP address to access the Service. This ensures that traffic is processed correctly. For more information about the annotation, see Set a hostname for a service.ImportantWhen you use this feature to bypass the CLB instance, avoid scheduling the client pod and the backend pod on the same node. Otherwise, access may fail because of asymmetric routing issues.
Notes on managing large-scale load balancing in a single cluster with CCM
CCM has a limited capacity for processing Service events. In large clusters with many nodes or many `LoadBalancer` Services, CCM might experience delays. These delays can occur during operations such as creating or deleting SLB instances and updating endpoints in server groups. This is common during batch creation or deletion of Services, simultaneous changes to many Service Endpoints, or when nodes are added or removed.
If your business requires large-scale batch changes, perform capacity assessments and stress testing in advance. This helps prevent business disruptions caused by CCM processing delays.
How to replace the SLB instance for a service
You cannot reuse or replace the SLB instance for an existing LoadBalancer Service. To replace the SLB instance, delete and then recreate the Service.
Quota limits
VPC
Each node in a cluster corresponds to one entry in the route table. By default, a VPC supports only 200 route table entries. If your cluster has more than 200 nodes, log on to the Quota Center console and submit an application.
For more information about VPC limits, see Limits and quotas.
To query VPC quotas, see VPC quota management.
Server Load Balancer
CCM creates an SLB instance for each
Type=LoadBalancerService. By default, a user can have up to 60 instances. If you need more than 60 instances, log on to the Quota Center console and submit an application.CCM attaches ECS instances or ENIs to the backend server group of the SLB instance based on the Service configuration.
CCM creates a separate server group for each targetPort in the Service. Therefore, when you calculate the backend server quota for an SLB instance, multiply it by the number of targetPorts.
By default, a single ECS instance or ENI can be attached to a maximum of 50 different backend server groups. If an ECS instance needs to be attached to more backend server groups, log on to the Quota Center console and submit an application.
By default, an SLB instance can have up to 200 backend servers. If you need more backend servers, log on to the Quota Center console and submit an application.
CCM creates listeners based on the ports defined in the Service. By default, an SLB instance can have up to 50 listeners. If you need more listeners, log on to the Quota Center console and submit an application.
For more information about SLB limits, see CLB limits and NLB limits.
To query SLB quotas, see Server Load Balancer quota management.
Load balancing update policies
ACK lets you specify an existing SLB instance for a Service or have CCM automatically create a new one. The resource update policies for these two methods differ, as shown in the following table.
Resource object | Specify an existing SLB instance | CCM-managed SLB instance |
Server Load Balancer | Set the
|
|
Listener | Set the
| CCM automatically creates and configures listener policies based on the service configuration. |
Backend server group | When the backend Endpoints of a service or the cluster nodes change, CCM automatically updates the backend vServer group of the SLB instance.
| |
Enable deletion protection for a service
You can enable deletion protection for Services that involve critical business operations or sensitive data. This prevents accidental deletions and associated costs. After you enable this feature, the corresponding resources can be deleted only after you manually disable deletion protection. For more information about how to enable deletion protection for a service, see Enable deletion protection for a service.