Updated on 2026-08-29 GMT+08:00

LoadBalancer Ingress Annotations

You can add annotations to a YAML file for more advanced ingress functions. This section describes the annotations that can be used when you create a LoadBalancer ingress.

Indexes

In a cluster, multiple ingresses can share a listener, allowing them to use the same port on a single load balancer. If two ingresses have different listener configurations, the listener configuration of the earlier ingress (known as the first route) will be used.

This case involves the following scenarios:

Ensure that the configurations of different listeners for various ingresses are synchronized.

Load Balancer Settings

Basic Configurations for Interconnecting with ELB

Application scenarios and use cases:
Table 1 Annotations for interconnecting with ELB

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.class

String

Select a proper load balancer type. This parameter cannot be modified after the ingress is created.

Options:

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

v1.9 or later

kubernetes.io/ingress.class

String

  • cce: A proprietary LoadBalancer ingress is used.
  • nginx: indicates that Nginx Ingress is used. This option is available only after NGINX Ingress Controller is installed. For details, see Creating an Nginx Ingress Using kubectl.

    Multiple NGINX Ingress Controller add-ons can be installed in a single cluster if the add-on version is 2.5.4 or later. In this case, the value of this parameter must be the controller name customized during controller installation, indicating that the ingress is managed by that specific controller.

This parameter is mandatory when you create an ingress. The default value is cce.

For clusters v1.23 or later, use the parameter ingressClassName. For details, see Creating a LoadBalancer Ingress Using kubectl.

Only clusters v1.21 or earlier

kubernetes.io/elb.port

String

External port registered with the LoadBalancer Service address.

The value ranges from 1 to 65535. The default value is 80 for HTTP and 443 for HTTPS.

NOTE:

Some ports on a shared load balancer are highly risky and blocked by default, for example, port 21.

v1.9 or later

kubernetes.io/elb.id

String

When associating only existing load balancers, you can use either this parameter or kubernetes.io/elb.ip. If they conflict, kubernetes.io/elb.id will take precedence. This parameter cannot be modified after the ingress is created.

This parameter indicates the ID of a load balancer.

How to obtain:

Log in to the ELB console and click the load balancer name. On the Summary tab of the load balancer details page, find the ID field and copy it.

v1.9 or later

kubernetes.io/elb.ip

String

When associating only existing load balancers, you can use either this parameter or kubernetes.io/elb.id. If they conflict, kubernetes.io/elb.id will take precedence. This parameter cannot be modified after the ingress is created.

This parameter indicates the IP address of a load balancer.

When creating an ingress, specify a public or private IP address for a shared load balancer. For a dedicated load balancer, only a private IP address can be specified.

v1.9 or later

kubernetes.io/elb.autocreate

Table 2 object

Mandatory when load balancers are automatically created. This parameter cannot be modified after the ingress is created.

CAUTION:

kubernetes.io/elb.id and kubernetes.io/elb.autocreate cannot be specified concurrently.

If both annotations are specified in a Service, CCE will use an existing load balancer instead of automatically creating one. If this Service is deleted, the existing load balancer is considered as an automatically created one. If no other resources are associated with the load balancer, the load balancer will also be deleted.

Example:

  • Automatically created dedicated load balancer with an EIP bound:

    '{"type":"public","bandwidth_name":"cce-bandwidth-1741230802502","bandwidth_chargemode":"bandwidth","bandwidth_size":5,"bandwidth_sharetype":"PER","eip_type":"5_bgp","available_zone":["*****"],"elb_virsubnet_ids":["*****"],"l7_flavor_name":"L7_flavor.elb.pro.max","l4_flavor_name":"","vip_subnet_cidr_id":"*****"}'

  • Automatically created dedicated load balancer with no EIP bound:

    '{"type":"inner","available_zone":["*****"],"elb_virsubnet_ids":["*****"],"l7_flavor_name":"L7_flavor.elb.pro.max","l4_flavor_name":"","vip_subnet_cidr_id":"*****"}'

  • Automatically created shared load balancer with an EIP bound:

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

  • Automatically created shared load balancer with no EIP bound:

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

v1.9 or later

kubernetes.io/elb.enterpriseID

String

Optional when load balancers are automatically created.

This parameter is available in clusters v1.15 or later. 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 EPS console. Click the enterprise project name. On the details page, copy the ID.

v1.15 or later

kubernetes.io/elb.subnet-id

String

Optional when load balancers are automatically created.

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

  • Mandatory when a cluster v1.11.7-r0 or earlier will be automatically created.
  • Optional for clusters of a version later than v1.11.7-r0.

Mandatory for clusters of a version earlier than v1.11.7-r0

Discarded in clusters of a version later than v1.11.7-r0

Adding Resource Tags

For details about applications and use cases, see Automatically Creating a Load Balancer While Creating an Ingress.

Table 3 Annotations

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.tags

String

Add resource tags to a load balancer. This parameter can be configured only when a load balancer is automatically created.

A tag is in the format of "key=value". Use commas (,) to separate multiple tags.

v1.23.11-r0, v1.25.6-r0, v1.27.3-r0, v1.23.8-r1, v1.25.3-r1, or later

Configuring a Reclaim Policy for an Auto-created Load Balancer

Table 4 Annotation for configuring a reclaim policy for an auto-created load balancer

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.instance-reclaim-policy

String

Optional when load balancers are automatically created.

Configure a reclaim policy for an auto-created load balancer. The options are as follows:

  • (Default) Absence of the parameter or presence as blank: The auto-created load balancer is deleted along with the Service/ingress. However, if the load balancer is associated with multiple Services/ingresses and the Service/ingress that is created along with the load balancer is deleted first, the load balancer may be retained even after all its associated Services/ingresses are deleted.
  • retain: The auto-created load balancer is retained when the Service/ingress is deleted.
  • alwaysDelete: The auto-created load balancer is deleted along with the Service/ingress. If the load balancer is associated with multiple Services/ingresses, it will be deleted only after all its associated Services/ingresses are deleted.
NOTE:
  • If an auto-created load balancer is associated with multiple Services/ingresses, this parameter applies only to the Service/ingress that is created along with the load balancer.

v1.28.15-r60, v1.29.15-r20, v1.30.14-r20, v1.31.10-r20, v1.32.6-r20, v1.33.5-r10, or later

The following shows how to use the preceding annotation:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-1
  namespace: default
  annotations:
    kubernetes.io/elb.port: '80'
    kubernetes.io/elb.class: performance
    kubernetes.io/elb.autocreate: '{"type":"inner","available_zone":["******"],"elb_virsubnet_ids":["*****"],"ipv6_vip_virsubnet_id":"******","l7_flavor_name":"L7_flavor.elb.pro.max","l4_flavor_name":"","vip_subnet_cidr_id":"******"}'
    kubernetes.io/elb.enterpriseID: '0'
    kubernetes.io/elb.instance-reclaim-policy: retain   # Configure a reclaim policy for an auto-created load balancer.
spec:
  rules:
    - host: ''
      http:
        paths:
          - path: /
            backend:
              service:
                name: service-1
                port:
                  number: 80
            property:
              ingress.beta.kubernetes.io/url-match-mode: STARTS_WITH
            pathType: ImplementationSpecific
  ingressClassName: cce

Certificate and Security Management

Configuring ELB Certificates

For details about applications and use cases, see Configuring an HTTPS Certificate for a LoadBalancer Ingress.

Table 5 ELB certificate annotations

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.tls-certificate-ids

String

ELB certificate IDs, which are separated by comma (,). The list length is greater than or equal to 1. The first ID in the list is the server certificate, and the other IDs are SNI certificates in which a domain name must be contained.

How to obtain: Log in to the ELB console and choose Certificates. In the certificate list, copy the ID under the target certificate name.

v1.19.16-r2, v1.21.5-r0, v1.23.3-r0, or later

kubernetes.io/elb.tls-ciphers-policy

String

The default value is tls-1-2, which is the default security policy used by the listener and takes effect only when HTTPS is used.

Options:

  • tls-1-0
  • tls-1-1
  • tls-1-2
  • tls-1-2-strict
  • tls-1-0-with-1-3 (dedicated load balancer)
  • tls-1-2-fs (dedicated load balancer)
  • tls-1-2-fs-with-1-3 (dedicated load balancer)

For details of cipher suites for each security policy, see Table 3.

Clusters v1.17.17 or later

kubernetes.io/elb.security_policy_id

String

The ID of the custom security group policy on ELB. Obtain it on the ELB console. This field takes effect only when HTTPS is used and has a higher priority than the default security policy.

For details about how to create and update a custom security policy, see TLS Security Policy.

Clusters v1.17.17 or later

Configuring Mutual Authentication

Table 6 Annotation for configuring mutual authentication

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.client-ca-cert-id

String

Required only for mutual authentication. The ELB certificate ID serves as the CA certificate.

How to obtain: Log in to the ELB console and choose Certificates. In the certificate list, copy the ID under the target certificate name.

Clusters v1.28.15-r60, v1.29.15-r20, v1.30.14-r20, v1.31.10-r20, v1.32.6-r20, v1.33.5-r10, or later support this configuration.

The following shows how to use the preceding annotation:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test
  namespace: default
  annotations:
    kubernetes.io/elb.port: '443'
    kubernetes.io/elb.id: *****
    kubernetes.io/elb.class: performance
    kubernetes.io/elb.tls-certificate-ids: *****
    kubernetes.io/elb.client-ca-cert-id: *****   # Configure mutual authentication.
spec:
  rules:
    - host: ''
      http:
        paths:
          - path: /
            backend:
              service:
                name: test
                port:
                  number: 80
            property:
              ingress.beta.kubernetes.io/url-match-mode: STARTS_WITH
            pathType: ImplementationSpecific
  ingressClassName: cce

Protocol and Listener Configuration

Using HTTP/2

For details about applications and use cases, see Configuring HTTP/2 for a LoadBalancer Ingress.

Table 7 Annotations for using HTTP/2

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.http2-enable

String

Whether HTTP/2 is enabled. Request forwarding using HTTP/2 improves access performance between your application and the load balancer. However, the load balancer still uses HTTP/1.x to forward requests to the backend server.

Options:

  • true: enabled
  • false: disabled (default value)

Note: HTTP/2 can be enabled or disabled only when the listener uses HTTPS. This parameter is invalid and defaults to false when the listener protocol is HTTP.

v1.23.13-r0, v1.25.8-r0, v1.27.5-r0, v1.28.3-r0, or later

Interconnecting with HTTPS Backend Services

For details about applications and use cases, see Configuring HTTPS Backend Services for a LoadBalancer Ingress.

Table 8 Annotations for interconnecting with HTTPS backend services

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.pool-protocol

String

To interconnect with HTTPS backend services, set this parameter to https.

v1.23.8, v1.25.3, or later

Routing and Forwarding Policies

Configuring Advanced Forwarding Rules

For details about applications and use cases, see Configuring an Advanced Forwarding Policy for a LoadBalancer Ingress.

Table 9 Annotation for advanced forwarding rules

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.conditions.${svc_name}

String

Configure advanced forwarding rules. ${svc_name} indicates the Service name, which can contain a maximum of 51 characters.

If the annotation value is set to [], the advanced forwarding rule will be deleted.

The annotation value is a JSON array. For details, see Table 4.

NOTICE:
  • Due to ELB API restrictions, a kubernetes.io/elb.conditions.{svcName} can contain a maximum of 10 key-value pairs.
  • The rules in a conditions array are connected by an AND relationship, while the values in the same rule block are connected by an OR relationship. For example, if both Method and QueryString are configured, the target traffic can be distributed only when both rules are met. However, if the Method value is GET or POST, the target traffic can be distributed only when both rules are met and the Method value must be GET or POST.

v1.23.18-r10, v1.25.16-r0, v1.27.16-r0, v1.28.13-r0, v1.29.8-r0, v1.30.4-r0, or later

Configuring Advanced Forwarding Actions

For details about applications and use cases, see Configuring an Advanced Forwarding Policy for a LoadBalancer Ingress.

Table 10 Annotation for configuring advanced forwarding actions

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.actions.${svc_name}

String

Advanced forwarding action of the Service associated with an ingress. ${svc_name} indicates the Service name, which can contain a maximum of 51 characters.

The annotation value is a JSON array. If it is set to [], the advanced forwarding action will be deleted.

The following advanced forwarding actions are supported:

The forwarding actions supported by clusters vary depending on the cluster version. For details, see Table 2.

Configuring URL Redirection

For details about applications and use cases, see Configuring URL Redirection for a LoadBalancer Ingress.

Table 11 Annotations for configuring URL redirection

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.redirect-url

String

URL for redirection.

Format:

  • HTTPS ingresses: valid URLs starting with https://, for example, https://example.com/
  • HTTP ingresses: valid URLs starting with http:// or https://, for example, https://example.com/

Parameter: This configuration takes effect on all forwarding rules of a single ingress. After the configuration is deleted, the target URL redirection rule will be automatically cleared.

Either this annotation or the annotation of a grayscale release can be configured.

v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0, or later

kubernetes.io/elb.redirect-url-code

String

Code returned after an ingress is redirected to a URL.

Format: The return code can be 301, 302, 303, 307, or 308.

Parameter: The default value is 301.

Configuring URL Rewriting

For details about applications and use cases, see Configuring URL Rewriting for a LoadBalancer Ingress.

Table 12 Annotations for configuring URL rewriting

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.rewrite-target

String

Information about the rewritten path.

Format: A proper rule matching a regular expression must start with a slash (/).

Parameter: This configuration takes effect on the URL of a single ingress matching the regular expression. After the configuration is deleted, the target URL rewriting rule will be automatically cleared.

Either this annotation or the annotation of a grayscale release can be configured.

v1.23.14-r0, v1.25.9-r0, v1.28.4-r0, or later

Redirecting HTTP to HTTPS

For details about applications and use cases, see Redirecting HTTP to HTTPS for a LoadBalancer Ingress.

Table 13 Annotations for redirecting HTTP to HTTPS

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.ssl-redirect

String

Whether to enable redirection from HTTP to HTTPS.

Format: The value can be true or false.

Parameter: true indicates that redirection is enabled. If the value is false or the parameter is unavailable, redirection is disabled.

NOTE:

Either this annotation or the annotation of a grayscale release can be configured.

If a dedicated load balancer is used, the cluster version must be v1.23.14-r0, v1.25.9-r0, v1.28.4-r0, or later.

If a shared load balancer is used, the cluster version must be v1.27.16-r50, v1.28.15-r40, v1.29.15-r0, v1.30.14-r0, v1.31.10-r0, v1.32.6-r0, v1.33.1-r0, or later.

Configuring the Priorities of Forwarding Rules

When ingresses use the same load balancer listener, forwarding rules can be prioritized based on the following rules:

  • Forwarding rules of different ingresses: The rules are sorted based on the priorities (ranging from 1 to 1000) of the kubernetes.io/elb.ingress-order annotation. A smaller value indicates a higher priority.
  • Forwarding rules of an ingress: If the kubernetes.io/elb.rule-priority-enabled annotation is set to true, the forwarding rules are sorted based on the sequence in which they are added during ingress creation. A forwarding rule added earlier indicates a higher priority. If the kubernetes.io/elb.rule-priority-enabled annotation is not configured, the default sorting of the forwarding rules on the load balancer will be used.

If the preceding annotations are not configured, the default sorting of the forwarding rules on the load balancer will be used, regardless of whether the forwarding rules are of the same ingress or different ingresses under the same load balancer listener.

For details about applications and use cases, see Configuring Forwarding Rule Priorities for LoadBalancer Ingresses.

Table 14 Annotations for configuring the priorities of forwarding rules

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.ingress-order

String

Specifies the sequence of forwarding rules of different ingresses. The value ranges from 1 to 1000. A smaller value indicates a higher priority. The priority of a forwarding rule must be unique under the same load balancer listener.

This parameter is available only for dedicated load balancers.

NOTE:
  • When this annotation is configured, the kubernetes.io/elb.rule-priority-enabled annotation is enabled by default. The forwarding rules of each ingress will be sorted.
  • CCE sorts all forwarding policies for a given listener based on the order of the ingresses and the forwarding policy settings within those ingresses. The configured value does not correspond to the priority of the load balancer forwarding policy.

v1.23.15-r0, v1.25.10-r0, v1.28.5-r0, or later

kubernetes.io/elb.rule-priority-enabled

String

This parameter can only be set to true, indicating to sort the forwarding rules of an ingress. The priorities of the forwarding rules are determined based on the sequence in which they are added during ingress creation. A forwarding rule added earlier indicates a higher priority.

If this parameter is not configured, the default sorting of the forwarding rules on the load balancer will be used. After this parameter is enabled, it cannot be disabled.

This parameter is available only for dedicated load balancers.

Configuring a Custom Header Forwarding Policy

For details about applications and use cases, see Configuring a Custom Header Forwarding Policy for a LoadBalancer Ingress.

Table 15 Annotations for configuring a custom header forwarding policy

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.headers.${svc_name}

String

Custom header of the Service associated with an ingress. ${svc_name} is the Service name.

Format: a JSON string, for example, {"key": "test", "values": ["value1", "value2"]}

  • A key-value pair represents the key and value of a custom header. You can configure up to nine values. However, if a header with the key host is specified, only eight values can be configured.

    Enter 1 to 40 characters for a key. Only letters, digits, hyphens (-), and underscores (_) are allowed.

    Enter 1 to 128 characters for a value. Asterisks (*) and question marks (?) are allowed, but spaces and double quotation marks are not allowed. An asterisk can match zero or more characters, and a question mark can match one character.

  • Either a custom header or grayscale release can be configured.
  • Enter 1 to 51 characters for ${svc_name}.

v1.23.16-r0, v1.25.11-r0, v1.28.6-r0, or later

Configuring an HTTP/HTTPS Header

For details about applications and use cases, see Configuring an HTTP/HTTPS Header for a LoadBalancer Ingress.

Table 16 Annotations for configuring an HTTP/HTTPS header

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.x-forwarded-port

String

A load balancer can obtain the port number of a listener using X-Forwarded-Port and include the port number into the packets sent to the backend server.

  • true: Enable the function of obtaining a listener port number.
  • false: Disable the function of obtaining a listener port number.

v1.23.13-r0, v1.25.8-r0, v1.27.5-r0, v1.28.3-r0, or later

kubernetes.io/elb.x-forwarded-for-port

String

A load balancer can obtain a client port number for requests using X-Forwarded-For-Port and include the port number into the packets sent to the backend server.

  • true: Enable the function of obtaining a client port number for requests.
  • false: Disable the function of obtaining a client port number for requests.

kubernetes.io/elb.x-forwarded-host

String

  • true: Enable the function of rewriting X-Forwarded-Host. Then, the X-Forwarded-Host header will be rewritten using the Host header of the client request and transmitted to backend servers.
  • false: Disable the function of rewriting X-Forwarded-Host. Then, the X-Forwarded-Host header of the client will be transmitted to backend servers.

Traffic and Performance Optimization

Configuring Timeout for an Ingress

For details about applications and use cases, see Configuring Timeout for a LoadBalancer Ingress.

Table 17 Annotations for configuring timeout of an ingress

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.keepalive_timeout

String

Timeout for client connections. If there are no requests reaching the load balancer during this period, the load balancer will disconnect the connection from the client and establish a new connection when there is a new request.

The value ranges from 0 to 4000 (in seconds). The default value is 60.

Dedicated load balancers: v1.19.16-r30, v1.21.10-r10, v1.23.8-r10, v1.25.3-r10, or later

Shared load balancers: v1.23.13-r0, v1.25.8-r0, v1.28.3-r0, or later

kubernetes.io/elb.client_timeout

String

Timeout for waiting for a request from a client. There are two cases:

  • If the client fails to send a request header to the load balancer during this period, the request will be interrupted.
  • If the interval between two consecutive request bodies reaching the load balancer exceeds this period, the connection will be disconnected.

The value ranges from 1 to 300 (in seconds). The default value is 60.

kubernetes.io/elb.member_timeout

String

Timeout for backend server response. After a request is forwarded to the backend server, if the backend server does not respond within the duration specified by member_timeout, the load balancer will stop waiting and return HTTP 504 Gateway Timeout.

The value ranges from 1 to 300 (in seconds). The default value is 60.

Configuring a Slow Start

For details about applications and use cases, see Configuring a Slow Start for a LoadBalancer Ingress.

Table 18 Annotations for configuring a slow start

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.slowstart

String

Duration of slow start, in seconds.

The slow start duration ranges from 30 to 1200.

  • This configuration applies only to dedicated load balancers.
  • This parameter is valid only when the allocation policy of the target Service is weighted round robin (WRR) and sticky session is disabled.
NOTE:

The load balancer linearly increases the proportion of requests to backend servers in slow start mode. When the configured slow start duration elapses, the load balancer sends full share of requests to backend servers and exits the slow start mode.

v1.23 or later

Enabling GZIP

For details about applications and use cases, see Configuring GZIP Data Compression for a LoadBalancer Ingress.

Table 19 Annotations for enabling GZIP

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.gzip-enabled

String

LoadBalancer ingresses support data compression, which reduces the size of files to be transferred, improves file transfer efficiency, and reduces the bandwidth needed for the transmission.

If this function is enabled, specific files will be compressed. If it is not enabled, files will not be compressed. By default, data compression is disabled.

The files in the following format can be compressed:

  • Brotli can compress all file formats.
  • GZIP can compress the files of the following types: text/xml, text/plain, text/css, application/javascript, application/x-javascript, application/rss+xml, application/atom+xml, application/xml, and application/json

This function is available only for HTTP/HTTPS listeners of dedicated load balancers. Deleting the advanced configuration for data compression or the target annotation will not modify the existing ELB settings.

v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0, or later

Network and Backend Configuration

Configuring a Custom EIP

For details about applications and use cases, see Configuring a Custom EIP for a LoadBalancer Ingress.

Table 20 Annotations of custom EIP configurations

Parameter

Type

Description

Supported Cluster Version

kubernetes.io/elb.custom-eip-id

String

ID of the custom EIP, which can be seen on the EIP console.

The EIP must be bindable.

v1.23.18-r0, v1.25.13-r0, v1.27.10-r0, v1.28.8-r0, v1.29.4-r0, v1.30.1-r0, or later