Use annotations in a Service YAML file to configure CLB instances, listeners, and backend server groups.
Index
|
Main content |
Quick links |
Annotations
-
Annotations are case-sensitive.
-
Check the required CCM version for each annotation before use. To upgrade CCM, see manage components. CCM change log: Cloud Controller Manager.
-
As of September 11, 2019, for
annotations, thealicloudprefix was updated toalibaba-cloud.For example:
Before the update:
service.beta.kubernetes.io/alicloud-loadbalancer-idAfter the update:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idThe system remains compatible with the
alicloudformat. No changes to existing configurations are required.
CLB operations
Create a public load balancer
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
type: LoadBalancer
Create a private load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type
|
Description |
Default |
Supported CCM versions |
|
Specifies the address type of the load balancer. Valid values:
|
internet |
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 load balancer specification
Annotation: Multiple, as shown in the following table.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type |
Specifies the instance billing method. Use
|
PayBySpec |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec |
The CLB instance specification. Use this annotation to create an instance with a specific specification or update an existing one. CreateLoadBalancer. Important
If you modify the specification in the CLB console (this operation is only supported for pay-by-specification instances), CCM may revert the change. |
slb.s1.small |
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 load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id
|
Description |
Default |
Supported CCM versions |
|
The ID of the load balancer instance. Use this annotation to specify an existing CLB instance.
|
None |
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}" # Multiple policy groups cannot be configured.
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancer
Use an existing load balancer and overwrite listeners
Annotation: Multiple, as shown in the following table. This operation forcibly overwrites existing listeners. If a listener port conflicts, the existing listener is deleted.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id |
The ID of the existing CLB instance.
|
||
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-force-override-listeners |
Specifies whether to forcibly overwrite the listeners of the CLB instance. Valid values:
Important
When you reuse an existing CLB and set |
"false" |
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 standby availability zones
Annotation: Multiple, as shown in the following table. The primary and standby availability zones cannot be changed after the instance is created.
Availability varies by region. Check the CLB instance creation page.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-master-zoneid |
The ID of the primary availability zone. |
None |
v1.9.3.10-gfb99107-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-slave-zoneid |
The ID of the standby availability zone. |
None |
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 pay-by-bandwidth load balancer
Annotation: Multiple, as shown in the following table. The following two annotations are required.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-charge-type |
The billing method of the load balancer instance. Valid values:
|
paybytraffic |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-bandwidth |
The peak bandwidth of the CLB instance. Applies only to public CLB instances. Change the billing method of a public load balancer instance. |
50 |
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 a vSwitch for a load balancer
Annotation: Multiple, as shown in the following table. The following two annotations are required.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type |
Specifies the address type of the load balancer. Valid values:
|
internet |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id |
The ID of the vSwitch to which the load balancer instance belongs. The vSwitch must be in the same VPC as the Kubernetes cluster. This annotation requires setting You can find the vSwitch ID in the VPC console. |
None |
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 an IP address for a private load balancer
Annotation: Multiple, as shown in the following table. The following three annotations are required.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type |
Specifies the address type of the load balancer. Valid values:
|
internet |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vswitch-id |
The ID of the vSwitch to which the load balancer instance belongs. The vSwitch must be in the same VPC as the Kubernetes cluster. This annotation requires setting You can find the vSwitch ID in the VPC console. |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip |
The IP address of the private load balancer instance.
|
None |
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 tags to a load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-additional-resource-tags
|
Description |
Default |
Supported CCM versions |
|
A comma-separated list of tags to add, for example, |
None |
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 load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip-version
|
Description |
Default |
Supported CCM versions |
|
The IP version of the load balancer instance. The IP version cannot be changed after the instance is created. To use this feature, kube-proxy in your cluster must run in IPVS mode. Valid values:
|
ipv4 |
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 a load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-delete-protection
|
Description |
Default |
Supported CCM versions |
|
Specifies whether deletion protection is enabled for the load balancer instance. Valid values:
Important
Note that if you enable deletion protection in the CLB console, the load balancer instance can still be deleted by running the |
on |
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 modification protection for a load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-modification-protection
|
Description |
Default |
Supported CCM versions |
|
Specifies the modification protection status for the load balancer instance. Valid values:
|
ConsoleProtection |
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 a load balancer name
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-name
|
Description |
Default |
Supported CCM versions |
|
The CLB instance name. Must be 2–128 characters, starting with a letter or Chinese character. Can contain digits, periods (.), underscores (_), and hyphens (-). |
None |
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 a resource group for a load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-resource-group-id
|
Description |
Default |
Supported CCM versions |
|
The ID of the resource group for the load balancer instance. The resource group ID cannot be changed once set. You can find resource group IDs in the Resource Management console. |
None |
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 a hostname for a Service
Annotation: Multiple, as shown in the following table.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with commas (,), for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-hostname |
Specifies a hostname for the Service. The hostname must conform to DNS naming conventions. Note the following:
|
None |
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/TCP,443/TCP 10s
Create a pay-by-consumption load balancer
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type
|
Description |
Default |
Supported CCM versions |
|
The instance billing method. Valid values:
Important
You cannot set a specification for a load balancer instance that is billed by consumption. The value |
PayBySpec |
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
Common listener actions
Configure TCP session persistence
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-persistence-timeout
|
Description |
Default |
Supported CCM versions |
|
Specifies the session persistence time for TCP listeners. If a load balancer instance has multiple TCP listeners, this setting applies to all of them by default. Value range: 0–3600 seconds. Default: 0 (session persistence disabled). CreateLoadBalancerTCPListener. |
0 |
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 a sticky session (insert cookie)
Multiple annotations are required, as shown in the following table. The insert cookie method requires three annotations.
-
This feature applies only to load balancer instances with HTTP or HTTPS listeners.
-
By default, this sticky session setting applies to all configured HTTP and HTTPS listeners.
|
Annotation |
Description |
Default |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session |
Enables or disables sticky sessions. This setting applies only to HTTP and HTTPS listeners. Valid values:
CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
off |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session-type |
Specifies the cookie handling method. This setting is effective only for HTTP and HTTPS listeners. This annotation is required when
CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie-timeout |
The cookie timeout in seconds. The valid range is 1 to 86,400. This annotation is required when CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie |
The name of the cookie that is configured on the server. The name must be 1 to 200 characters long and contain only ASCII letters and digits. It cannot contain commas (,), semicolons (;), or spaces, and must not start with a dollar sign ($). This annotation is required when CreateLoadBalancerHTTPListener and CreateLoadBalancerHTTPSListener. |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Specifies the listener port(s) to which the sticky session settings apply. By default, the settings apply to all listeners. Separate multiple entries with a comma (,). Example: |
None |
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 an access control list
Note: The three annotations in the following table are required.
Before using these annotations, create an access control list in the Classic Load Balancer (CLB) console and record its ID.
|
Annotation |
Description |
Default |
Supported versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-status |
Specifies whether to enable access control. Valid values:
|
off |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-id |
The ID of the access control list to associate with the listener. This parameter is required when |
None |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-type |
Access control type. Possible values:
|
None |
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}"
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
Configure port forwarding for a load balancer
Port forwarding redirects requests from an HTTP port to an HTTPS port.
Annotations: The following three annotations are required.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with a comma, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
The Alibaba Cloud certificate ID. Log in 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. |
None |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-forward-port |
Forwards HTTP requests to an HTTPS port, for example, |
None |
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
Load balancer scheduling algorithm
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler
|
Description |
Default |
Supported versions |
|
The scheduling algorithm. Valid values:
|
rr |
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 a 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 an HTTP listener
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port
|
Description |
Default |
Supported CCM versions |
|
Separate multiple values with commas, for example, |
None |
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 an HTTPS listener
Annotation: For the required annotations, see the following table.
The CLB layer decrypts HTTPS requests and sends them to backend Pods as HTTP requests.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with commas, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
The Alibaba Cloud certificate ID. 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. |
None |
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
Create a listener with a health check
Configure a TCP health check
Annotations: The following table lists the required annotations.
By default, health checks are enabled for TCP ports.
|
Annotation |
Description |
Default |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch |
Specifies whether to enable health checks for TCP and UDP listeners. Valid values:
|
on |
v2.6.0 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type |
The health check type. Valid values:
|
tcp |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout |
The time to wait for a health check response, in seconds. If a backend server does not respond within this period, the health check fails. Valid values: 1–300. If the value of |
5 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold |
The number of consecutive successful health checks required to change a backend server's status from Valid values: 2–10. CreateLoadBalancerTCPListener. |
3 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold |
The number of consecutive failed health checks required to change a backend server's status from |
3 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval |
The interval between health checks, in seconds. Valid values: 1–50. CreateLoadBalancerTCPListener. |
2 |
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
Configure UDP health checks
Annotation: Multiple, as shown in the table below. All the following annotations are required.
By default, health checks are enabled for UDP ports.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch |
Specifies whether to enable health checks for TCP and UDP listeners. Valid values:
|
on |
v2.6.0 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout |
The response timeout for a health check. This parameter applies to UDP listeners. If a backend server fails to respond within this timeout, the health check fails. Unit: seconds. Value range: [1, 300]. If the value of |
5 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold |
The number of consecutive successful health checks required to change a backend server's status from Value range: [2, 10]. CreateLoadBalancerUDPListener. |
3 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold |
The number of consecutive failed health checks required to change a backend server's status from |
3 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval |
The interval between health checks. Unit: seconds. Value range: [1, 50]. CreateLoadBalancerUDPListener. |
2 |
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 checks for TCP and UDP
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch
|
Description |
Default |
Supported CCM versions |
|
Specifies whether to enable health checks for TCP and UDP listeners. Valid values:
|
on |
v2.6.0 or later |
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-switch: "off" # Disable the health check.
name: nginx
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
type: LoadBalancer
Configure an HTTP health check
Annotation: Multiple, as shown in the following table.
|
Annotation |
Description |
Default |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-flag |
Valid values:
|
off |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type |
The protocol for the health check. Valid values:
|
tcp |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-uri |
The URI path for the health check. This annotation is required only for HTTP health checks. |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-httpcode |
The HTTP status codes that indicate a successful health check. Separate multiple values with a comma. Valid values:
|
http_2xx |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-domain |
The domain name used for the health check. Valid values:
|
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-timeout |
The time, in seconds, to wait for a response to an HTTP health check. If no response is received within this period, the health check fails. Unit: seconds. Valid values: 1 to 300. If the value of |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold |
The number of consecutive successful health checks required before a backend server is considered healthy (status changes from fail to success). Valid values: 2 to 10. CreateLoadBalancerHTTPListener. |
3 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold |
The number of consecutive failed health checks required before a backend server is considered unhealthy (status changes from success to fail). Valid values: 2 to 10. CreateLoadBalancerHTTPListener. |
3 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval |
The interval between health checks. Unit: seconds. Valid values: 1 to 50. CreateLoadBalancerHTTPListener. |
2 |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with a comma, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-method |
The HTTP method to use for the health check. Valid values:
|
None |
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 the HTTP status code for the health check (optional)
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-httpcode: "http_4xx"
# Set the domain name for the health check (optional)
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-domain: "www.aliyun.com"
# Set the 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
Connection drain
Annotation: Multiple, as shown in the following table. All of these annotations are required.
Only TCP and UDP are supported.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain |
Enables or disables connection drain. Valid values:
|
None |
v2.0.1 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-connection-drain-timeout |
Sets the connection drain timeout in seconds. The valid range is 10 to 900. |
None |
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 a listener
Configuration: Use the annotations in the following table to configure this feature.
This feature supports only HTTP and HTTPS listeners.
|
Annotation |
Description |
Default |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with a comma, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-proto |
Specifies whether to use the X-Forwarded-Proto header field to retrieve the listener protocol of the CLB instance. Valid values:
|
off |
v2.1.0 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-slbport |
Specifies whether to use the XForwardedFor_SLBPORT header field to retrieve the listener port of the load balancer instance. Valid values:
|
off |
v2.9.1 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-xforwardedfor-clientsrcport |
Specifies whether to use the XForwardedFor_ClientSrcPort header field to retrieve the client's source port. Valid values:
|
off |
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 timeout for a listener
Annotations: See the table below.
This feature only supports listeners that use the HTTP or HTTPS protocol.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with a comma (,), for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-idle-timeout |
Specifies the idle timeout for the listener. Unit: seconds. Valid values: [1, 60]. |
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 a listener
Annotation: Multiple annotations are used, as shown in the following table.
This feature is available only for HTTPS listeners.
|
Annotation |
Description |
Default |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Use a comma (,) to separate multiple values, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
The certificate ID on Alibaba Cloud. Log on to the CLB console and find the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
None |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-http2-enabled |
Enables or disables the HTTP/2 feature. Valid values:
|
on |
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
Request timeout for a listener
Annotations: The required annotations are listed in the following table.
This feature supports only listeners that use the HTTP or HTTPS protocol.
|
Annotation |
Description |
Default |
Supported CCM version |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with a comma, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-request-timeout |
Specifies the request timeout in seconds. The value must be between 1 and 180. If a backend server does not respond within the specified timeout, the load balancer returns an HTTP 504 error to the client. |
60 |
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
Specify connection timeout
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-established-timeout
Only TCP listeners are supported.
|
Description |
Default |
Supported CCM version |
|
Specifies the connection timeout in seconds. The value must be an integer from 10 to 900. CreateLoadBalancerTCPListener. |
None |
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 a listener security policy
Annotations: See the table below for the required annotations.
Only the HTTPS protocol is supported.
|
Annotation |
Description |
Default |
Supported CCM versions |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port |
Separate multiple values with a comma, for example, |
None |
v1.9.3 and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id |
Specifies the ID of an Alibaba Cloud certificate. In the SLB console, find the certificate ID on the Certificates page. Note
To create a certificate, see Select an Alibaba Cloud-issued certificate. |
None |
v1.9.3.164-g2105d2e-aliyun and later |
|
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-tls-cipher-policy |
Specifies the security policy, which determines the TLS protocol versions and supported cipher suites for an HTTPS listener. CreateLoadBalancerHTTPSListener. Valid values:
|
tls_cipher_policy_1_0 |
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 TCP and UDP
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
|
Description |
Default |
Supported versions |
|
Enables Proxy Protocol for TCP and UDP listeners. When enabled, the load balancer passes the client source address to backend servers. Valid values:
Important
This feature does not support seamless migration. Enabling or disabling Proxy Protocol requires a service upgrade, causing a service interruption. Configure this setting with caution. |
off |
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
Backend server group operations
Reuse an existing virtual server group
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-vgroup-port. This annotation enables you to reuse an existing virtual server group. It applies only when you reuse an existing CLB instance. For a detailed example, see Deploy Services across clusters by reusing an existing load balancer.
Set Service traffic weight
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-weight
When multiple Services reuse the same CLB instance, use this annotation to set the traffic weight for the current Service. This setting applies only when you reuse an existing virtual server group. For a detailed example, see Deploy Services across clusters by reusing an existing load balancer.
Skip backend server weight updates
Annotation: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ignore-weight-update
|
Description |
Supported CCM versions |
|
Skips updating the weights of backend servers in the virtual server group during Service synchronization. This allows you to manually manage backend server weights. 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