Updated on 2022-09-24 GMT+08:00

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

Description

kubernetes.io/elb.class

Select a proper load balancer type.

Value:

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

kubernetes.io/elb.id

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 Network > Elastic Load Balance. Click the name of the target load balancer. On the Summary tab page, find and copy the ID.

kubernetes.io/elb.subnet-id

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.

kubernetes.io/elb.enterpriseID

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.

kubernetes.io/elb.autocreate

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":"traffic","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"}

kubernetes.io/elb.lb-algorithm

Load balancing algorithm of the backend server group. The default value is ROUND_ROBIN.

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.

kubernetes.io/elb.health-check-flag

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.

kubernetes.io/elb.health-check-option

ELB health check configuration items.

kubernetes.io/elb.session-affinity-mode

Listeners ensure session stickiness based on IP addresses. Requests from the same IP address will be routed 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.

kubernetes.io/elb.session-affinity-option

Sticky session timeout.

kubernetes.io/hws-hostNetwork

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.