Service Annotations
CCE allows you to add annotations to a YAML file to realize some advanced Service functions. The following table describes the annotations you can add.
The annotations of a Service are the parameters that need to be specified for connecting to a load balancer. For details about how to use the annotations, see Using kubectl to Create a Service (Automatically Creating a Load Balancer).
| Parameter | Type | Description | Default Value | Supported Cluster Version |
|---|---|---|---|---|
| kubernetes.io/elb.class | String | Select a proper load balancer type. Value:
Default value: union | union | v1.9 or later |
| kubernetes.io/elb.id | String | ID of a load balancer. The value can contain 1 to 100 characters. Mandatory when an existing load balancer is to be associated. How to obtain: On the management console, click Service List, and choose Networking > Elastic Load Balance. Click the name of the target load balancer. On the Summary tab page, find and copy the ID. | None | v1.9 or later |
| kubernetes.io/elb.protocol-port | String | Layer-7 forwarding configuration port used by the Service. | None | v1.21 or later |
| kubernetes.io/elb.cert-id | String | HTTP certificate used by the Service for Layer-7 forwarding. | None | v1.21 or later |
| kubernetes.io/elb.subnet-id | String | ID of the subnet where the cluster is located. The value can contain 1 to 100 characters.
| None | Mandatory for versions earlier than v1.11.7-r0 Discarded in versions later than v1.11.7-r0 |
| kubernetes.io/elb.enterpriseID | String | Clusters of v1.15 and later versions support this field. In clusters earlier than v1.15, load balancers are created in the default project by default. This parameter indicates the ID of the enterprise project in which the ELB load balancer will be created. If this parameter is not specified or is set to 0, resources will be bound to the default enterprise project. How to obtain: Log in to the management console and choose Enterprise > Project Management on the top menu bar. In the list displayed, click the name of the target enterprise project, and copy the ID on the enterprise project details page. | 0 | v1.15 or later |
| kubernetes.io/elb.autocreate | Whether to automatically create a load balancer associated with the Service. Example:
| None | v1.9 or later | |
| kubernetes.io/elb.lb-algorithm | String | Specifies the load balancing algorithm of the backend server group. Value:
When the value is SOURCE_IP, the weights of backend servers in the server group are invalid. | ROUND_ROBIN | v1.9 or later |
| kubernetes.io/elb.health-check-flag | String | Whether to enable the ELB health check. Disabled by default.
| off | v1.9 or later |
| kubernetes.io/elb.health-check-option | ELB health check configuration items. | None | v1.9 or later | |
| kubernetes.io/elb.pass-through | String | Whether the access requests from within the cluster to the Service pass through the ELB load balancer. For details about the application scenarios, see Enabling Passthrough Networking for LoadBalancer Services. | None | v1.19 or later |
| kubernetes.io/elb.session-affinity-mode | String | Listeners ensure session stickiness based on IP addresses. Requests from the same IP address will be forwarded to the same backend server.
| None | v1.9 or later |
| kubernetes.io/elb.session-affinity-option | Sticky session timeout. | None | v1.9 or later | |
| kubernetes.io/hws-hostNetwork | Boolean | Whether the workload Services use the host network. Setting this parameter to true will enable the load balancer to forward requests to the host network. The host network is not used by default. The value can be true or false. | false | v1.9 or later |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | No | String | Name of the load balancer that is automatically created. Value range: 1 to 64 characters, including lowercase letters, digits, and underscores (_). The value must start with a lowercase letter and end with a lowercase letter or digit. Default name: cce-lb+service.UID |
| type | No | String | Network type of the load balancer.
Default value: inner |
| bandwidth_name | Yes for public network load balancers | String | Bandwidth name. The default value is cce-bandwidth-******. Value range: 1 to 64 characters, including lowercase letters, digits, and underscores (_). The value must start with a lowercase letter and end with a lowercase letter or digit. |
| bandwidth_chargemode | No | String | Bandwidth billing mode.
Default value: bandwidth |
| bandwidth_size | Yes for public network load balancers | Integer | Bandwidth size. The default value is 1 to 2000 Mbit/s. Set this parameter based on the bandwidth range allowed in your region. |
| bandwidth_sharetype | Yes for public network load balancers | String | Bandwidth sharing mode.
|
| eip_type | Yes for public network load balancers | String | EIP type.
|
| vip_subnet_cidr_id | No | String | Subnet where the ELB load balancer is located. This field is supported by clusters of v1.21 or later. If this parameter is not specified, the ELB load balancer and the cluster are in the same subnet. |
| available_zone | Yes | Array of strings | AZ where the load balancer is located. This parameter is available only for dedicated load balancers. |
| l4_flavor_name | Yes | String | Flavor name of the layer-4 load balancer. You can obtain all supported types by querying the flavor list. This parameter is available only for dedicated load balancers. |
| l7_flavor_name | No | String | Flavor name of the layer-7 load balancer. You can obtain all supported types by querying the flavor list. This parameter is available only for dedicated load balancers. |
| elb_virsubnet_ids | No | Array of strings | Subnet where the backend server of the load balancer is located. If this parameter is left blank, the default cluster subnet is used. Load balancers occupy different number of subnet IP addresses based on their specifications. Therefore, you are not advised to use the subnet CIDR blocks of other resources (such as clusters and nodes) as the load balancer CIDR block. This parameter is available only for dedicated load balancers. Example: "elb_virsubnet_ids": [ "14567f27-8ae4-42b8-ae47-9f847a4690dd" ] |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| delay | No | String | Initial waiting time (in seconds) for starting the health check. Value range: 1 to 50. Default value: 5 |
| timeout | No | String | Health check timeout, in seconds. Value range: 1 to 50. Default value: 10 |
| max_retries | No | String | Maximum number of health check retries. Value range: 1 to 10. Default value: 3 |
| protocol | No | String | Health check protocol. Default value: protocol of the associated Service Value options: TCP, UDP_CONNECT, or HTTP |
| path | No | String | Health check URL. This parameter needs to be configured when the protocol is HTTP. Default value: / The value can contain 1 to 10,000 characters. |
Last Article: Headless Service
Next Article: Enabling Passthrough Networking for LoadBalancer Services
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.