To enable rich load balancing features, configure CLB instances, listeners, and backend server groups by adding annotations to your Service YAML file.
Index
|
Category |
Feature category |
Configuration link |
|
Create load balancer |
||
|
Specify existing instance |
||
|
Configure load balancer |
||
|
Enable instance protection |
||
|
Session persistence settings |
||
|
Port and protocol configuration |
||
|
Advanced Configuration |
|
|
|
Configuration Management |
|
|
Annotation usage notes
-
Annotation values are case-sensitive.
-
Before using annotations, check the supported CCM component version for each feature in this document. To upgrade the CCM component, see Components. For CCM component change records, see Cloud Controller Manager.
-
Starting September 11, 2019, the prefix for the
annotationsfield changed fromalicloudtoalibaba-cloud.Example:
Before update:
service.beta.kubernetes.io/alicloud-loadbalancer-idAfter update:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idThe system remains compatible with the
alicloudprefix. No changes are required.
Typical 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: LoadBalancer
Create an internal-facing SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type
|
Description |
Supported CCM version |
|
Specify the SLB instance as internal-facing. Valid values:
Default value: See Specify vSwitch for SLB instance to manually specify a vSwitch for the CLB. If not specified, the system automatically selects one based on the CCM version:
|
v1.9.3 and 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: LoadBalancer
Specify SLB instance specification
Annotation: Multiple, as listed in the following table.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type |
Billing method for the instance. Valid values:
Default value: Important
|
v2.4.0 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec |
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 specification in the CLB console (only supported for specification-billed SLB instances), CCM might revert it to the original specification. Proceed with caution. |
v1.9.3 and 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: LoadBalancer
Use an existing SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id
|
Description |
Supported CCM version |
|
Important
ID of the SLB instance. Use this annotation to specify an existing CLB.
|
v1.9.3.81-gca19cd4-aliyun and 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: LoadBalancer
Use an existing SLB instance and forcibly override existing listeners
Annotation: Multiple, as listed in the following table. Forcibly overriding existing listeners deletes conflicting listeners.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id |
Important
To avoid unexpected behaviors such as cluster unavailability or traffic interruption, do not reuse API Server CLB instances 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 CLB.
|
v1.9.3.81-gca19cd4-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-force-override-listeners |
When binding to an existing SLB, determines whether to synchronize CLB listener configurations based on the Service.
Default value: Important
When reusing an existing CLB and setting |
v1.9.3.81-gca19cd4-aliyun and 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: LoadBalancer
Specify primary and secondary zones when creating an SLB instance
Annotation: Multiple, as listed in the following table. Primary and secondary zones cannot be modified after creation.
SLB instances in some regions do not support primary and secondary zones. Refer to the CLB creation page for details.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-master-zoneid |
Zone ID of the primary backend server. |
v1.9.3.10-gfb99107-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-slave-zoneid |
Zone ID of the backup backend server. |
v1.9.3.10-gfb99107-aliyun and 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: LoadBalancer
Create a bandwidth-billed SLB instance
Annotation: Multiple, as listed in the following table. Both annotations are required.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-charge-type |
Billing method for the SLB instance. Valid values:
Default value: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-bandwidth |
Bandwidth of the SLB instance, representing peak bandwidth. Default value: 50. Applies only to Internet-facing SLB instances. For other limits, see Modify billing method for Internet-facing SLB instance. |
v1.9.3.10-gfb99107-aliyun and 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: LoadBalancer
Specify vSwitch for SLB instance
Annotation: Multiple, as listed in the following table. Both annotations are required.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type |
Specify the SLB instance as internal-facing. Valid values:
Default value: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id |
VSwitch ID of the SLB instance. The vSwitch must belong to the same VPC as the Kubernetes cluster. When setting this parameter, also set Log on to the Virtual Private Cloud console to query the vSwitch ID. |
v1.9.3 and 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: LoadBalancer
Specify IP address for internal-facing SLB
Annotation: Multiple, as listed in the following table. All three annotations are required.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type |
Specify the SLB instance as internal-facing. Valid values:
Default value: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id |
VSwitch ID of the SLB instance. The vSwitch must belong to the same VPC as the Kubernetes cluster. When setting this parameter, also set Log on to the Virtual Private Cloud console to query the vSwitch ID. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip |
IP address of the internal-facing SLB instance.
|
v2.7.0 and 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: nginx
Add additional tags to SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-additional-resource-tags
|
Description |
Supported CCM version |
|
List of tags to add. Separate multiple tags with English commas (,). Example: Important
After adding this annotation to specify additional tags, any manual tag modifications made to the corresponding SLB instance in the console may be overwritten. |
v1.9.3 and 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: LoadBalancer
Create an IPv6 SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip-version
|
Description |
Supported CCM version |
|
IP version of the SLB instance. The IP type cannot be changed after creation. When using this feature, ensure the kube-proxy proxy mode of your cluster is IPVS. Valid values:
Default value: |
v1.9.3.220-g24b1885-aliyun and 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: LoadBalancer
Enable deletion protection for SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-delete-protection
|
Description |
Supported CCM version |
|
Deletion protection for SLB instance. Valid values:
Default value: Important
For SLB instances created by LoadBalancer-type Services, even if you manually enable deletion protection in the CLB console, you can still delete the associated SLB instance by running |
v1.9.3.313-g748f81e-aliyun and 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: LoadBalancer
Enable configuration read-only mode for SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-modification-protection
|
Description |
Supported CCM version |
|
Configuration modification protection for SLB instance. Valid values:
Default value: |
v1.9.3.313-g748f81e-aliyun and 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: LoadBalancer
Specify SLB instance name
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-name
|
Description |
Supported CCM version |
|
Name of the SLB instance. The name must be 2–128 characters long, start with a letter or Chinese character, and can contain digits, periods (.), underscores (_), and hyphens (-). |
v1.9.3.313-g748f81e-aliyun and 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: LoadBalancer
Specify resource group for SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-resource-group-id
|
Description |
Supported CCM version |
|
Resource group ID of the SLB instance. Once specified, the resource group ID cannot be modified. Query the resource group ID in the Alibaba Cloud Resource Management console. |
v1.9.3.313-g748f81e-aliyun and 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: LoadBalancer
Set hostname for Service
Annotation: Multiple, as listed in the following table.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-hostname |
Set a hostname for the Service. The hostname must comply with DNS naming rules. Note the following:
|
v2.3.0 and 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: LoadBalancer
Expected 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 10s
Create a usage-based billed SLB instance
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type
|
Description |
Supported CCM version |
|
Billing method for the instance. Valid values:
Default value: Important
|
v2.4.0 and 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: LoadBalancer
Typical listener operations
Configure session persistence timeout for TCP SLB
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-persistence-timeout
|
Description |
Supported CCM version |
|
Session persistence timeout. Applies only to TCP listeners. If the SLB instance has multiple TCP listeners, this setting applies to all TCP listeners by default. Unit: seconds. Valid range: [0, 3600]. Default value: 0 (session persistence disabled). For more information, see CreateLoadBalancerTCPListener. |
v1.9.3 and 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: LoadBalancer
Configure session persistence (insert cookie) for HTTP and HTTPS listeners
Annotation: Multiple, as listed in the following table. All four annotations are required when inserting cookies.
-
Applies only to HTTP and HTTPS SLB instances.
-
If multiple HTTP or HTTPS listeners are configured, session persistence applies to all HTTP and HTTPS listeners 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 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session-type |
Cookie handling method. Applies only to HTTP and HTTPS listeners. Required when
For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie-timeout |
Cookie timeout. Required when For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie |
Cookie name configured on the server. Length: 1–200 characters. Can contain only ASCII letters and digits. Cannot contain commas (,), semicolons (;), spaces, or start with a dollar sign ($). Required when For more information, see CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and 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: LoadBalancer
Configure access control policy group for SLB
Annotation: Multiple, as listed in the following table. All three annotations are required.
Before using this annotation to create an SLB with access control, create an access control policy group in the Classic Load Balancer CLB console and record its ID (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 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-id |
ID of the access control policy group bound to the listener. Required when |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-type |
Access control type. Valid values:
|
v1.9.3.164-g2105d2e-aliyun and 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}" # Does not support multiple policy groups.
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: LoadBalancer
Specify redirection port for SLB
Port forwarding redirects HTTP requests to HTTPS ports.
Annotation: Multiple, as listed 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 English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
Certificate ID on Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-forward-port |
Forward HTTP requests to a specified HTTPS port. Example: |
v1.9.3.164-g2105d2e-aliyun and 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: LoadBalancer
Set scheduling algorithm for SLB
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler
|
Description |
Supported CCM version |
|
Scheduling algorithm. Valid values:
Default value: For more valid values, see the |
v1.9.3 and 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: LoadBalancer
Create UDP listener
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: UDP
targetPort: 80
selector:
run: nginx
type: LoadBalancer
Create HTTP listener
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port
-
Health check: HTTP listener health checks are disabled by default. To ensure backend service availability, configure HTTP or TCP health checks for the listener port.
-
In-cluster access: When accessing the service via CLB IP from within the cluster, request traffic might be truncated internally, causing access issues. See Set hostname for Service to force traffic through the CLB by adding an annotation. For details, see Notes on accessing LoadBalancer Service External IP from within the cluster.
|
Description |
Supported CCM version |
|
Separate multiple values with English commas (,). Example: |
v1.9.3 and 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: LoadBalancer
Create HTTPS listener
Annotation: Multiple, as listed in the following table.
HTTPS requests are decrypted at the CLB layer and sent to backend pods as HTTP requests.
-
Health check: HTTPS listener health checks are disabled by default. To ensure backend service availability, configure HTTP or TCP health checks for the listener port.
-
In-cluster access: When accessing the service via CLB IP from within the cluster, request traffic might be truncated internally, causing access issues. See Set hostname for Service to force traffic through the CLB by adding an annotation. For details, see Notes on accessing LoadBalancer Service External IP from within the cluster.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
Certificate ID on Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
v1.9.3.164-g2105d2e-aliyun and 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: LoadBalancer
SSL protocol error when accessing CLB from within a cluster
Symptoms
After you Create HTTPS listener for a service, the service works correctly when accessed from outside the cluster. However, when you use curl to access the HTTPS port of the CLB 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 number
Cause
This issue occurs because of the IP Virtual Server (IPVS) rules on the node:
-
Service configuration: An HTTPS listener on a CLB supports only the HTTP protocol for backend services. Therefore, the service must be configured to forward traffic from
port: 443totargetPort: 80. ACK then creates an IPVS rule on the node. This rule directly forwards traffic from port443to the backend port80. -
Layer 4 forwarding: IPVS operates at Layer 4 of the TCP/IP protocol stack. It only forwards TCP data packets and does not parse application-layer protocols such as TLS or HTTPS.
-
Protocol mismatch: The client (curl) sends an HTTPS request that contains TLS handshake data. IPVS directly forwards this request to the backend service's HTTP port
80. Because this port is not configured for TLS, it cannot parse the TLS request. As a result, the backend service returns an HTTP400error, and 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 generated on the nodes and forces traffic within the cluster to pass through the CLB. This ensures that the CLB correctly handles the TLS handshake. For more information, see .
Configure additional domain name certificates for HTTPS listener
Annotation: Multiple, as listed in the following table.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
Certificate ID on Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-domain-extensions |
Specify additional domain names and certificate IDs in the format Log on to the CLB console and view the certificate ID on the Certificates page. |
v2.13.0 and 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: LoadBalancer
Create listener with health check
Set TCP health check
Annotation: Multiple, as listed in the following table. All annotations are required.
TCP ports have health checks 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 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type |
Health check type. Valid values:
Default value: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout |
Time to wait for a response from the health check, applicable to TCP mode. If the backend ECS does not respond correctly within the specified time, the health check fails. Unit: seconds. Valid range: [1, 300]. If the value of |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold |
Number of consecutive successful health checks required to change the backend server's health status from Valid range: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerTCPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold |
Number of consecutive failed health checks required to change the backend server's health status from success to fail. Valid range: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerTCPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval |
Health check interval. Unit: seconds. Valid range: [1, 50]. Default value: 2. For more information, see CreateLoadBalancerTCPListener. |
v1.9.3 and 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: LoadBalancer
Set UDP health check
Annotation: Multiple, as listed in the following table. All annotations are required.
UDP ports have health checks 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 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout |
Time to wait for a response from the health check, applicable to TCP mode. If the backend ECS does not respond correctly within the specified time, the health check fails. Unit: seconds. Valid range: [1, 300]. If the value of |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold |
Number of consecutive successful health checks required to change the backend server's health status from fail to success. Valid range: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerUDPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold |
Number of consecutive failed health checks required to change the backend server's health status from success to fail. Valid range: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerUDPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval |
Health check interval. Unit: seconds. Valid range: [1, 50]. Default value: 2. For more information, see CreateLoadBalancerUDPListener. |
v1.9.3 and 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: LoadBalancer
Disable health check 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 and 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: LoadBalancer
Set HTTP health check
Annotation: Multiple, as listed 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 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type |
Health check type. Valid values:
Default value: For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-uri |
URI for health checks. Not required when health check type is TCP. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-httpcode |
HTTP status codes indicating a healthy check. Separate multiple status codes with English commas. Valid values:
Default value: For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-domain |
Domain name for health checks. Valid values:
For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-timeout |
Time to wait for a response from the health check, applicable to HTTP mode. If the backend ECS does not respond correctly within the specified time, the health check fails. Unit: seconds. Valid range: [1, 300]. If the value of For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold |
Number of consecutive successful health checks required to change the backend server's health status from fail to success. Valid range: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold |
Number of consecutive failed health checks required to change the backend server's health status from success to fail. Valid range: [2, 10]. Default value: 3. For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval |
Health check interval. Unit: seconds. Valid range: [1, 50]. Default value: 2. For more information, see CreateLoadBalancerHTTPListener. |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-method |
Health check method for HTTP listeners. Valid values:
|
v2.3.0 and 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"
# Set HTTP status code for health check (optional)
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-httpcode: "http_4xx"
# Set domain for health check (optional)
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-domain: "www.aliyun.com"
# Set health check method (optional)
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: LoadBalancer
Set connection draining for listener
Annotation: Multiple, as listed 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 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain-timeout |
Set connection draining timeout. Unit: seconds. Valid range: [10, 900]. |
v2.0.1 and 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: LoadBalancer
Configure additional request headers for listener
Annotation: Multiple, as listed 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 English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-proto |
Configure whether to obtain the CLB listener protocol via the X-Forwarded-Proto header. Valid values:
Default value: |
v2.1.0 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-slbport |
Configure whether to obtain the SLB instance listener port via the XForwardedFor_SLBPORT header. Valid values:
Default value: |
v2.9.1 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-clientsrcport |
Configure whether to obtain the client port accessing the SLB instance via the XForwardedFor_ClientSrcPort header. Valid values:
Default value: |
v2.9.1 and 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: LoadBalancer
Set idle connection timeout for listener
Annotation: Multiple, as listed 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 English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idle-timeout |
Set idle connection timeout for the listener. Unit: seconds. Valid range: [1, 60]. Default value: 15 |
v2.1.0 and 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: LoadBalancer
Disable HTTP/2 for listener
Annotation: Multiple, as listed in the following table.
Applies only to HTTPS protocol.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
Certificate ID on Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-http2-enabled |
Enable HTTP/2. Valid values:
Default value: |
v2.1.0 and 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: LoadBalancer
Set request timeout for listener
Annotation: Multiple, as listed 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 English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-request-timeout |
Set request timeout. Unit: seconds. Valid range: [1, 180]. Default value: 60 If the backend server does not respond within the timeout period, the SLB stops waiting and returns an HTTP 504 error to the client. |
v2.3.0 and 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: LoadBalancer
Set connection timeout for listener
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-established-timeout
Applies only to TCP protocol.
|
Description |
Supported CCM version |
|
Connection timeout. Unit: seconds. Valid range: [10, 900]. For more information, see CreateLoadBalancerTCPListener. |
v2.3.0 and 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: LoadBalancer
Configure security policy for listener
Annotation: Multiple, as listed in the following table.
Applies only to HTTPS protocol.
|
Annotation |
Description |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with English commas (,). Example: |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
Certificate ID on Alibaba Cloud. Log on to the CLB console and view the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-tls-cipher-policy |
Security policy includes optional TLS versions and encryption cipher suites for HTTPS. For more information, see CreateLoadBalancerHTTPSListener. Valid values:
Default value: |
v2.4.0 and 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: LoadBalancer
Configure both TCP and UDP protocols for listener
This feature requires Kubernetes cluster version v1.24 or later. For upgrade instructions, see Upgrade ACK cluster Kubernetes version.
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: LoadBalancer
Configure Proxy Protocol for TCP and UDP listeners
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-proxy-protocol
When accessing the service via CLB IP from within the cluster, request traffic might be truncated internally, causing access issues. See Set hostname for Service to force traffic through the CLB by adding an annotation. For details, see Notes on accessing LoadBalancer Service External IP from within the cluster.
|
Description |
Supported CCM version |
|
Configure Proxy Protocol for TCP and UDP listeners. When enabled, Proxy Protocol carries the client source address to backend servers. Valid values:
Default value: Important
This feature does not support smooth migration. Switching Proxy Protocol requires service downtime. Configure with caution. |
v2.6.0 and 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: LoadBalancer
Typical 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 worker nodes to mount to the CLB backend using labels. Separate multiple labels with English commas (,). Example: |
v1.9.3 and 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: LoadBalancer
Use nodes where pods reside as backend servers
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler
The default externalTrafficPolicy is Cluster mode, which mounts all cluster nodes to the backend. Local mode mounts only nodes where pods reside.
|
Description |
Supported CCM version |
|
Scheduling algorithm. Valid values:
Default value: |
v1.9.3 and 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: LoadBalancer
Remove nodes inunschedulable state from CLB backend
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 and 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: LoadBalancer
Mount pod ENIs directly to CLB backend
Annotation: service.beta.kubernetes.io/backend-type
|
Description |
Default value |
Supported CCM version |
|
CLB backend server type. Valid values:
|
|
v1.9.3.164-g2105d2e-aliyun and 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: LoadBalancer
Reuse existing vServer group
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vgroup-port
Supports reusing existing vServer groups. Applies only when reusing existing CLB instances. For usage examples, see Achieve cross-cluster service deployment by reusing existing SLB instances.
Set traffic weight for Service
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-weight
In scenarios where multiple Services reuse the same CLB, use this annotation to set the traffic weight for the current Service. This annotation applies only when reusing existing vServer groups. For usage examples, see Achieve cross-cluster service deployment by reusing existing SLB instances.
Ignore backend server weight updates
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ignore-weight-update
|
Description |
Supported CCM version |
|
Skip updating backend server weights in the vServer group during Service synchronization. Use this setting when managing backend server weights manually outside CCM. Valid values:
Default value: |
v2.11.1 and 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
Set default backend server weight
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-default-weight
|
Description |
Supported CCM version |
|
Set the default weight for servers in the server group. Higher weights result in more request traffic. Valid range: [0, 100]. If unspecified, the system uses the default weight corresponding to the current network type. This setting does not apply when the backend instance is ECS and the Service's |
v2.14.0 and later |
apiVersion: v1
kind: Service
metadata:
annotations:
# Set default server weight in server group to 35
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-default-weight: "35"
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancer