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).

Table 1 Service annotations

Parameter

Type

Description

Default Value on the Console

Supported Cluster Version

kubernetes.io/elb.class

String

Select a proper load balancer type.

The value can be:

  • union: shared load balancer

  • performance: dedicated load balancer, which can be used only in clusters of v1.17 and later.

performance

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.subnet-id

String

ID of the subnet where the cluster is located. The value can contain 1 to 100 characters.

  • Mandatory when a cluster of v1.11.7-r0 or earlier is to be automatically created.

  • Optional for clusters later than v1.11.7-r0.

None

Mandatory for versions earlier than v1.11.7-r0

Discarded in versions later than v1.11.7-r0

kubernetes.io/elb.autocreate

Table 2

Whether to automatically create a load balancer associated with the Service.

Example:

  • If a public network load balancer will be automatically created, set this parameter to the following value:

    {"type":"public","bandwidth_name":"cce-bandwidth-1551163379627","bandwidth_chargemode":"bandwidth","bandwidth_size":5,"bandwidth_sharetype":"PER","eip_type":"5_bgp","name":"james"}

  • If a private network load balancer will be automatically created, set this parameter to the following value:

    {"type":"inner","name":"A-location-d-test"}

None

v1.9 or later

kubernetes.io/elb.lb-algorithm

String

Specifies the load balancing algorithm of the backend server group.

Value:

  • ROUND_ROBIN: weighted round robin algorithm

  • LEAST_CONNECTIONS: weighted least connections algorithm

  • SOURCE_IP: source IP hash algorithm

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.

  • Enabling health check: Leave blank this parameter or set it to on.

  • Disabling health check: Set this parameter to off.

If this parameter is enabled, the kubernetes.io/elb.health-check-option field must also be specified at the same time.

off

v1.9 or later

kubernetes.io/elb.health-check-option

Table 3

ELB health check configuration items.

None

v1.9 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.

  • Disabling sticky session: Do not set this parameter.

  • Enabling sticky session: Set this parameter to SOURCE_IP, indicating that the sticky session is based on the source IP address.

None

v1.9 or later

kubernetes.io/elb.session-affinity-option

Table 4

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 value is true or false.

The default value is false, indicating that the host network is not used.

None

v1.9 or later

Table 2 Data structure of the elb.autocreate field

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: cce-lb+service.UID

type

No

String

Network type of the load balancer.

  • public: public network load balancer

  • inner: private network load balancer

Default: 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 mode.

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.

  • PER: dedicated bandwidth

eip_type

Yes for public network load balancers

String

EIP type.

  • 5_bgp: dynamic BGP

  • 5_sbgp: static BGP

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.

This parameter is available only for dedicated load balancers.

l7_flavor_name

No

String

Flavor name of the layer-7 load balancer.

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"
 ]
Table 3 Data structure description of the elb.health-check-option field

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, 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.

Table 4 Data structure of the elb.session-affinity-option field

Parameter

Mandatory

Type

Description

persistence_timeout

Yes

String

Sticky session timeout, in minutes. This parameter is valid only when elb.session-affinity-mode is set to SOURCE_IP.

Value range: 1 to 60. Default value: 60