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

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.

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

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.

Disabled by default.

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

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

  • 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 host network is not used by default. The value can be true or false.

false

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

type

No

String

Network type of the load balancer.

  • public: public network load balancer
  • inner: private network 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.

  • bandwidth: billed by bandwidth
  • traffic: billed by traffic

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.

  • PER: dedicated bandwidth

eip_type

Yes for public network load balancers

String

EIP type.

  • 5_telcom: China Telecom
  • 5_union: China Unicom
  • 5_bgp: dynamic BGP
  • 5_sbgp: static BGP

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"
 ]
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_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.

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