You can use advanced load balancing features by adding annotations to your Service YAML file to configure CLB instances, listeners, and backend server groups.
Index
Category | Feature category | Configuration link |
Create a load balancer | ||
Use an existing instance | ||
Configure the load balancer | ||
Enable instance protection | ||
Configure session persistence | ||
Configure ports and protocols | ||
Advanced configuration | ||
Configuration management | ||
Annotation usage notes
Annotation values are case-sensitive.
Before using an annotation, verify the supported Cloud Controller Manager (CCM) version in this topic. To upgrade CCM, see Manage components. For CCM release notes, see Cloud Controller Manager.
Starting September 11, 2019, the
annotationsfield changed fromalicloudtoalibaba-cloud.For example:
Before:
service.beta.kubernetes.io/alicloud-loadbalancer-idAfter:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idThe system still supports the
alicloudformat. You do not need to make any changes.
Common CLB operations
Create an Internet-facing SLB instance
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCreate an internal-facing SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type
Description | Supported CCM version |
Specify whether the SLB instance is internal-facing. Valid values:
Default value: We recommend that you manually specify a vSwitch for the SLB instance. See Specify a vSwitch for the SLB instance. If you do not specify one, the system selects one automatically based on the CCM version:
| v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerSpecify the SLB instance specification
Annotation: Multiple, as shown in the following table.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type | The billing method for the SLB instance. Valid values:
Default value: Important
| v2.4.0 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec | The specification of the SLB instance. Use this parameter to create an SLB instance with a specific specification or update the specification of an existing SLB instance. Valid values:
Default value: For more valid values, see CreateLoadBalancer. Important If you modify the SLB instance specification in the CLB console (only supported for pay-by-specification SLB instances), CCM may revert it to the original specification. Proceed with caution. | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type: "PayBySpec"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec: "slb.s1.small"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerUse an existing SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id
Description | Supported CCM version |
Important
The ID of the SLB instance. Use this annotation to specify an existing CLB instance.
| v1.9.3.81-gca19cd4-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id: "${YOUR_LOADBALANCER_ID}"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerUse an existing SLB instance and force override existing listeners
Annotation: Multiple, as shown in the following table. Force override deletes existing listeners if port conflicts occur.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id | Important To avoid unexpected behavior such as cluster unavailability or traffic interruption, do not reuse the API Server CLB instance or CLB instances created by CCM. Create a new instance manually in the Classic Load Balancer (CLB) console. The ID of the SLB instance. Use this annotation to specify an existing Server Load Balancer.
| v1.9.3.81-gca19cd4-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-force-override-listeners | Determines whether CCM synchronizes CLB listener configurations with the Service when binding to an existing SLB instance.
Default value: Important When reusing an existing CLB and setting | v1.9.3.81-gca19cd4-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id: "${YOUR_LOADBALANCER_ID}"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-force-override-listeners: "true"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerSpecify primary and secondary zones when creating an SLB instance
Annotation: Multiple, as shown in the following table. After creation, primary and secondary zones cannot be modified.
Some regions do not support primary and secondary zones for SLB instances. Check the CLB console for details.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-master-zoneid | The zone ID of the primary backend server. | v1.9.3.10-gfb99107-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-slave-zoneid | The zone ID of the backup backend server. | v1.9.3.10-gfb99107-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-master-zoneid: "cn-hangzhou-k"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-slave-zoneid: "cn-hangzhou-j"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCreate a bandwidth-based SLB instance
Annotation: Multiple, as shown in the following table. Both annotations are required.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-charge-type | The billing method for the SLB instance. Valid values:
Default value: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-bandwidth | The bandwidth limit for the SLB instance, in Mbps. Default value: 50. Applies only to Internet-facing SLB instances. For other limits, see Modify the billing method for an Internet-facing SLB instance. | v1.9.3.10-gfb99107-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-charge-type: "paybybandwidth"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-bandwidth: "2"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerSpecify a vSwitch for the SLB instance
Annotation: Multiple, as shown in the following table. Both annotations are required.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type | Specify whether the SLB instance is internal-facing. Valid values:
Default value: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id | The VSwitch ID for the SLB instance. The VSwitch must belong to the same VPC as the Kubernetes cluster. When you set this parameter, also set You can find the VSwitch ID in the Virtual Private Cloud (VPC) console. | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id: "${YOUR_VSWITCH_ID}"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerSpecify an IP address for an internal-facing SLB instance
Annotation: Multiple, as shown in the following table. All three annotations are required.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type | Specify whether the SLB instance is internal-facing. Valid values:
Default value: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id | The VSwitch ID for the SLB instance. The VSwitch must belong to the same VPC as the Kubernetes cluster. When you set this parameter, also set You can find the VSwitch ID in the Virtual Private Cloud (VPC) console. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip | The IP address for the internal-facing SLB instance.
| v2.7.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id: "${YOUR_VSWITCH_ID}"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip: "192.168.x.x"
name: nginx
namespace: default
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
name: http
selector:
app: nginxAdd extra tags to the SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-additional-resource-tags
Description | Supported CCM version |
A list of tags to add. Separate multiple tags with commas (,). Example: Important Adding this annotation to set extra tags may overwrite manual tag modifications made in the console for the corresponding SLB instance. | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-additional-resource-tags: "Key1=Value1,Key2=Value2"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCreate an IPv6 SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip-version
Description | Supported CCM version |
The IP version for the SLB instance. You cannot change the IP version after creation. The kube-proxy proxy mode for the cluster must be IPVS. Valid values:
Default value: | v1.9.3.220-g24b1885-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip-version: "ipv6"
name: nginx
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerEnable deletion protection for the SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-delete-protection
Description | Supported CCM version |
Enable deletion protection for the SLB instance. Valid values:
Default value: Important For SLB instances created by LoadBalancer Services, you can still delete the associated SLB instance using | v1.9.3.313-g748f81e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-delete-protection: "on"
name: nginx
spec:
externalTrafficPolicy: Local
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerEnable configuration modification protection for the SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-modification-protection
Description | Supported CCM version |
Enable configuration modification protection for the SLB instance. Valid values:
Default value: | v1.9.3.313-g748f81e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-modification-protection: "ConsoleProtection"
name: nginx
spec:
externalTrafficPolicy: Local
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerSpecify the SLB instance name
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-name
Description | Supported CCM version |
The name of the SLB instance. Length: 2–128 characters. Must start with a letter or Chinese character. Can contain letters, digits, periods (.), underscores (_), and hyphens (-). | v1.9.3.313-g748f81e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-name: "your-svc-name"
name: nginx
spec:
externalTrafficPolicy: Local
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerSpecify the resource group for the SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-resource-group-id
Description | Supported CCM version |
The resource group ID for the SLB instance. You cannot change the resource group ID after assignment. Find the resource group ID in the Alibaba Cloud Resource Management console. | v1.9.3.313-g748f81e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-resource-group-id: "rg-xxxx"
name: nginx
spec:
externalTrafficPolicy: Local
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerSet a hostname for the Service
Annotation: Multiple, as shown in the following table.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-hostname | Set a hostname for the Service. The hostname must comply with DNS naming rules. Important notes:
| v2.3.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-hostname: "${your_service_hostname}"
name: nginx-svc
namespace: default
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerExpected output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-svc loadBalancer 47.100.XX.XX www.example.com 80:30248/TCP,443:32670/TCP 10sCreate a pay-by-usage SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type
Description | Supported CCM version |
The billing method for the SLB instance. Valid values:
Default value: Important
| v2.4.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type: "PayByCLCU"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerPreserve automatically created SLB instances when deleting a Service
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-preserve-lb-on-delete
Description | Supported CCM version |
When deleting a LoadBalancer Service, preserve the SLB instance created by the Service and remove the When enabled, a Warning event of type Valid values:
Important Delete the Service instead of changing its type to perform this operation. Otherwise, the Service may incorrectly reattach to a previously preserved SLB instance. | v2.10.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-preserve-lb-on-delete: "true"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCommon listener operations
Configure session persistence timeout for TCP SLB instances
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-persistence-timeout
Description | Supported CCM version |
The session persistence timeout. Applies only to TCP listeners. If the SLB instance has multiple TCP listeners, this setting applies to all of them. Unit: seconds. Valid values: [0, 3600]. Default value: 0, which disables session persistence. For more information, see CreateLoadBalancerTCPListener. | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-persistence-timeout: "1800"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerConfigure session persistence (insert cookie) for HTTP and HTTPS listeners
Annotation: Multiple, as shown in the following table. All four annotations are required when inserting cookies.
Applies only to HTTP and HTTPS SLB instances.
If you configure multiple HTTP or HTTPS listener ports, this session persistence setting applies to all of them by default.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session | Enable session persistence. Applies only to HTTP and HTTPS listeners. Valid values:
Default value: For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session-type | The cookie handling method. Applies only to HTTP and HTTPS listeners. Required when
For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie-timeout | The cookie timeout. Required when For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie | The cookie name configured on the server. Length: 1–200 characters. Can contain only ASCII letters and digits. Cannot contain commas (,), semicolons (;), or spaces. Cannot start with a dollar sign ($). Required when For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session-type: "insert"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie-timeout: "1800"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure an access control policy group for the SLB instance
Annotation: Multiple, as shown in the following table. All three annotations are required.
Before using this annotation, create an access control policy group in the Classic Load Balancer (CLB) console and record the ACL ID.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-status | Enable access control. Valid values:
Default value: | v1.9.3.164-g2105d2e-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-id | The ACL ID to attach to the listener. Required when | v1.9.3.164-g2105d2e-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-type | The access control type. Valid values:
| v1.9.3.164-g2105d2e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-status: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-id: "${YOUR_ACL_ID}" # Multiple policy groups are not supported.
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-type: "white"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerSpecify the redirection port for the SLB instance
Port forwarding redirects HTTP requests to an HTTPS port.
Annotation: Multiple, as shown in the following table. All three annotations are required.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id | The certificate ID in Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificate Management page. Note To create a certificate, see Select an Alibaba Cloud-issued certificate. | v1.9.3.164-g2105d2e-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-forward-port | Redirect HTTP requests to an HTTPS port. Example: | v1.9.3.164-g2105d2e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "https:443,http:80"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id: "${YOUR_CERT_ID}"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-forward-port: "80:443"
name: nginx
namespace: default
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: 80
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerSet the scheduling algorithm for the SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler
Description | Supported CCM version |
The scheduling algorithm. Valid values:
Default value: For more valid values, see the | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler: "wrr"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerCreate a UDP listener
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: UDP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCreate an HTTP listener
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port
Health check: Health checks for HTTP listeners are disabled by default. To ensure backend service availability, configure HTTP or TCP health checks for the listener port.
Access from inside the cluster: When accessing the service via the CLB IP from inside the cluster, traffic may be intercepted internally, causing access failures. See Set a hostname for the Service to force traffic to route through the CLB by adding an annotation. For details, see Notes on accessing the External IP of a LoadBalancer Service from inside the cluster.
Description | Supported CCM version |
Separate multiple values with commas (,). Example: | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCreate an HTTPS listener
Annotation: Multiple, as shown in the following table.
HTTPS requests are decrypted at the CLB layer and sent to backend pods as HTTP requests.
Health check: Health checks for HTTPS listeners are disabled by default. To ensure backend service availability, configure HTTP or TCP health checks for the listener port.
Access from inside the cluster: When accessing the service via the CLB IP from inside the cluster, traffic may be intercepted internally, causing access failures. See Set a hostname for the Service to force traffic to route through the CLB by adding an annotation. For details, see Notes on accessing the External IP of a LoadBalancer Service from inside the cluster.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id | The certificate ID in Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificate Management page. Note To create a certificate, see Select an Alibaba Cloud-issued certificate. | v1.9.3.164-g2105d2e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "https:443"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id: "${YOUR_CERT_ID}"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerSSL protocol errors when accessing CLB from inside the cluster
Issue
After you create an HTTPS listener for a Service, the service is accessible from outside the cluster. However, when you use curl to access the HTTPS port of the CLB instance associated with the Service from a node or Pod inside the cluster, the following error is returned:
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version numberCause
This issue is caused by IPVS rules on the node:
Service configuration: Because CLB HTTPS listeners support only HTTP as the backend protocol, the Service forwards traffic from
port: 443totargetPort: 80. ACK creates IPVS rules on the node to forward traffic destined for port443directly to port80on the backend.Layer 4 forwarding: IPVS operates at Layer 4 of the TCP/IP stack and forwards only TCP packets. It does not parse application-layer protocols like TLS/HTTPS.
Protocol mismatch: The client (curl) sends an HTTPS request (TLS handshake data) that IPVS forwards directly to the HTTP port
80on the backend service. Since this port is not configured for TLS, it cannot parse the TLS request and returns an HTTP400error. The client reports an SSL protocol error.
Solution
Add the service.beta.kubernetes.io/alibaba-cloud-loadbalancer-hostname annotation to the Service. This annotation prevents IPVS rules from being created on the node and forces traffic from inside the cluster to route through the CLB, ensuring TLS is handled correctly at the CLB. For detailed steps, see .
Configure extended domain name certificates for HTTPS listeners
Annotation: Multiple, as shown in the following table.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id | The certificate ID in Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificate Management page. Note To create a certificate, see Select an Alibaba Cloud-issued certificate. | v1.9.3.164-g2105d2e-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-domain-extensions | Specify extended domain names and their certificate IDs in the format Log on to the CLB console and view the certificate ID on the Certificate Management page. | v2.13.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "https:443"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id: "${YOUR_CERT_ID}"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-domain-extensions: "${DOMAIN_1}:${CERT_ID_1},${DOMAIN_2}:${CERT_ID_2}"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerCreate a listener with health checks
Configure TCP health checks
Annotation: Multiple, as shown in the following table. All annotations are required.
TCP port health checks are enabled by default.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch | Enable health checks for TCP and UDP listeners. Valid values:
Default value: | v2.6.0 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type | The health check type. Valid values:
Default value: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout | The time to wait for a response from the health check. Applies to TCP mode. If the backend ECS does not respond correctly withinthe specified time, the health check fails. Unit: seconds. Valid values: [1, 300]. If the value of | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold | The number of consecutive successful health checks required to change the backend server's status from Valid values: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerTCPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold | The number of consecutive failed health checks required to change the backend server's status from success to fail. Valid values: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerTCPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval | The health check interval. Unit: seconds. Valid values: [1, 50]. Default value: 2. For more information, see CreateLoadBalancerTCPListener. | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type: "tcp"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout: "8"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold: "4"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold: "4"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval: "3"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure UDP health checks
Annotation: Multiple, as shown in the following table. All annotations are required.
UDP port health checks are enabled by default.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch | Enable health checks for TCP and UDP listeners. Valid values:
Default value: | v2.6.0 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout | The time to wait for a response from the health check. Applies to TCP mode. If the backend ECS does not respond correctly within the specified time, the health check fails. Unit: seconds. Valid values: [1, 300]. If the value of | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold | The number of consecutive successful health checks required to change the backend server's status from fail to success. Valid values: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerUDPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold | The number of consecutive failed health checks required to change the backend server's status from success to fail. Valid values: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerUDPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval | The health check interval. Unit: seconds. Valid values: [1, 50]. Default value: 2. For more information, see CreateLoadBalancerUDPListener. | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval: "5"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout: "10"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold: "3"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold: "3"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: UDP
targetPort: 80
selector:
run: nginx
type: LoadBalancerDisable health checks for TCP and UDP listeners
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch
Description | Supported CCM version |
Enable health checks for TCP and UDP listeners. Valid values:
Default value: | v2.6.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch: "off" # Disable health check
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerConfigure HTTP health checks
Annotation: Multiple, as shown in the following table.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-flag | Valid values:
Default value: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type | The health check type. Valid values:
Default value: For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-uri | The URI for the health check. This annotation is not required for TCP health checks. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-httpcode | The HTTP status codes for a successful health check. Separate multiple codes with commas (,). Valid values:
Default value: For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-domain | The domain name for the health check. Valid values:
For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-timeout | The time to wait for a response from the health check. Applies to HTTP mode. If the backend ECS does not respond correctly within the specified time, the health check fails. Unit: seconds. Valid values: [1, 300]. If the value of For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold | The number of consecutive successful health checks required to change the backend server's status from fail to success. Valid values: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold | The number of consecutive failed health checks required to change the backend server's status from success to fail. Valid values: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval | The health check interval. Unit: seconds. Valid values: [1, 50]. Default value: 2. For more information, see CreateLoadBalancerHTTPListener. | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-method | The health check method for HTTP listeners. Valid values:
| v2.3.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-flag: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type: "http"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-uri: "/test/index.html"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold: "4"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold: "4"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-timeout: "10"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval: "3"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
# Optional. Set the HTTP status code for the health check.
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-httpcode: "http_4xx"
# Optional. Set the domain name for the health check.
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-domain: "www.aliyun.com"
# Optional. Set the health check method.
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-method: "head"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure connection draining for the listener
Annotation: Multiple, as shown in the following table. All annotations are required.
Applies only to TCP and UDP protocols.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain | Enable connection draining. Valid values:
| v2.0.1 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain-timeout | Set the connection draining timeout. Unit: seconds. Valid values: [10, 900]. | v2.0.1 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain-timeout: "30"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure additional request headers for the listener
Annotation: Multiple, as shown in the following table.
Applies only to HTTP and HTTPS protocols.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-proto | Configure whether to use the X-Forwarded-Proto header to get the CLB listener protocol. Valid values:
Default value: | v2.1.0 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-slbport | Configure whether to use the XForwardedFor_SLBPORT header to get the SLB instance listener port. Valid values:
Default value: | v2.9.1 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-clientsrcport | Configure whether to use the XForwardedFor_ClientSrcPort header to get the port of the client accessing the SLB instance. Valid values:
Default value: | v2.9.1 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-proto: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-slbport: "on"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-clientsrcport: "on"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerSet the idle connection timeout for the listener
Annotation: Multiple, as shown in the following table.
Applies only to HTTP and HTTPS protocols.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idle-timeout | Set the idle connection timeout for the listener. Unit: seconds. Valid values: [1, 60]. Default value: 15 | v2.1.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idle-timeout: "30"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerDisable HTTP/2 for the listener
Annotation: Multiple, as shown in the following table.
Applies only to the HTTPS protocol.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id | The certificate ID in Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificate Management page. Note To create a certificate, see Select an Alibaba Cloud-issued certificate. | v1.9.3.164-g2105d2e-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-http2-enabled | Enable HTTP/2. Valid values:
Default value: | v2.1.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "https:443"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id: "${YOUR_CERT_ID}"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-http2-enabled: "off"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure the request timeout for the listener
Annotation: Multiple, as shown in the following table.
Applies only to HTTP and HTTPS protocols.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-request-timeout | Specify the request timeout. Unit: seconds. Valid values: [1, 180]. Default value: 60 If the backend server does not respond within the timeout period, the SLB instance stops waiting and returns an HTTP 504 error code to the client. | v2.3.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-request-timeout: "60"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerSet the connection timeout for the listener
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-established-timeout
Applies only to the TCP protocol.
Description | Supported CCM version |
The connection timeout. Unit: seconds. Valid values: [10, 900]. For more information, see CreateLoadBalancerTCPListener. | v2.3.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-established-timeout: "60"
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure a security policy for the listener
Annotation: Multiple, as shown in the following table.
Applies only to the HTTPS protocol.
Annotation | Description | Supported CCM version |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port | Separate multiple values with commas (,). Example: | v1.9.3 or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id | The certificate ID in Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificate Management page. Note To create a certificate, see Select an Alibaba Cloud-issued certificate. | v1.9.3.164-g2105d2e-aliyun or later |
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-tls-cipher-policy | The security policy includes optional TLS versions and their corresponding encryption algorithm suites for HTTPS. For more information, see CreateLoadBalancerHTTPSListener. Valid values:
Default value: | v2.4.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "https:443,http:80"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id: "${YOUR_CERT_ID}"
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-tls-cipher-policy: "tls_cipher_policy_1_2"
name: nginx
namespace: default
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: 443
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerConfigure both TCP and UDP protocols for a listener
This feature requires Kubernetes v1.24 or later. To upgrade your cluster, see Upgrade an ACK cluster.
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
ports:
- name: tcp
port: 80
protocol: TCP
targetPort: 80
- name: udp
port: 80
protocol: UDP
targetPort: 81
selector:
app: nginx
sessionAffinity: None
type: LoadBalancerConfigure Proxy Protocol for TCP and UDP listeners
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-proxy-protocol
When you access a Service through a CLB IP within a cluster, request traffic may be intercepted internally, resulting in abnormal access. For more information, see Setting a Hostname for a Service, which describes how to add an annotation to force traffic to bypass the CLB. For details, see Considerations for Accessing the External IP of a LoadBalancer Service from Within a Cluster.
Description | Supported CCM version |
Configure Proxy Protocol for TCP and UDP listeners. After configuration, Proxy Protocol can carry the client's source address to the backend server. Valid values:
Default value: Important This feature does not support smooth online migration. Switching Proxy Protocol requires a service outage for the upgrade. Configure with caution. | v2.6.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-proxy-protocol: "on"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerCommon backend server group operations
Use Worker nodes with specified labels as backend servers
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-backend-label
Description | Supported CCM version |
Specify which Worker nodes to attach to the CLB backend using labels. Separate multiple labels with commas (,), for example, | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-backend-label: "failure-domain.beta.kubernetes.io/zone=ap-southeast-5a"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancerUse nodes where Pods run as backend servers
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler
By default, externalTrafficPolicy is set to Cluster mode, which attaches all nodes in the cluster to the backend server group. Local mode attaches only the nodes where the Pods are running.
Description | Supported CCM version |
The scheduling algorithm. Valid values:
Default value: | v1.9.3 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler: "wrr"
name: nginx
namespace: default
spec:
externalTrafficPolicy: Local
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancerRemove unschedulable nodes from the CLB backend server group
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-remove-unscheduled-backend
Description | Supported CCM version |
Remove SchedulingDisabled nodes from the CLB backend. Valid values:
Default value: | v1.9.3.164-g2105d2e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-remove-unscheduled-backend: "on"
name: nginx
spec:
externalTrafficPolicy: Local
ports:
- name: http
port: 30080
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerMount Pod ENIs directly to the CLB backend
Annotation: service.beta.kubernetes.io/backend-type
Description | Default value | Supported CCM version |
The CLB backend server type. Valid values:
|
| v1.9.3.164-g2105d2e-aliyun or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/backend-type: "eni"
name: nginx
spec:
ports:
- name: http
port: 30080
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancerReuse an existing vServer group
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vgroup-port
Supports reusing an existing vServer group. This is effective only when reusing an existing CLB instance. For a usage example, see Deploy services across clusters by reusing an existing SLB instance.
Set the traffic weight for the Service
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-weight
When multiple Services reuse the same CLB instance, you can use this annotation to set the traffic weight for the current Service. This annotation is effective only when reusing an existing vServer group. For a usage example, see Deploy services across clusters by reusing an existing SLB instance.
Ignore updates to backend server weights
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ignore-weight-update
Description | Supported CCM version |
During Service synchronization, skip updating the weights of backend servers in the vServer group. This configuration is suitable for scenarios where you need to manually manage backend server weights using mechanisms other than CCM. Valid values:
Default value: | v2.11.1 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ignore-weight-update: "on"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancer