All Products
Search
Document Center

Container Service for Kubernetes:Configure hybrid, cross-region, and on-premises backends

Last Updated:Mar 24, 2026

ALB Ingress supports using the alb.ingress.kubernetes.io/actions.<service-name> annotation to configure backend server groups. Backend server groups can be attached by service name or server group ID, which enables hybrid attachment of Pods within a K8s cluster and ECS instances outside the cluster. By combining products such as ALB, Cloud Enterprise Network (CEN), and transit routers, you can enable ALB to forward requests to servers in VPCs of other regions for cross-region attachment, or to on-premises IDC servers for on-premises IDC attachment. This topic describes how to use ALB Ingress to implement hybrid, cross-region, and on-premises IDC attachments.

Table of contents

Usage notes

  • The service name in the alb.ingress.kubernetes.io/actions.<service-name> annotation must match the service name of the backend in the rule field.

  • When you configure a backend server group, in the rule field, the service port name under backend must be use-annotation.

  • You can use the alb.ingress.kubernetes.io/actions.<service name> annotation to attach multiple server groups to an ALB instance.

  • A basic ALB instance supports a maximum of five server groups.

  • When you attach a server group by using both ServerGroupID and ServiceName+ServicePort, the system prioritizes ServerGroupID to match the backend server group.

Scenario 1: Forward requests to multiple services

Prerequisites

Scenario

As shown in the following figure, with the multi-server group forwarding action of ALB Ingress, you can create or attach multiple backend server groups by configuring ServiceName+ServicePort to forward requests to multiple Services within the cluster.

image

Procedure

  1. Configure the ALB Ingress.

    Deploy the following content to the tea-ingress.yaml file. This defines how requests are forwarded to multiple Services within the cluster.

    # This Ingress forwards requests to different backend server groups based on the hostname and path, with traffic distributed according to weights.
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: tea-ingress
      annotations:
        alb.ingress.kubernetes.io/actions.forward: |
           [{
               "type": "ForwardGroup",
               "ForwardConfig": {
                 "ServerGroups" : [{
                   "ServiceName": "tea-svc",
                   "Weight": 80,
                   "ServicePort": 80
                 },
                 {
                   "ServiceName": "coffee-svc",
                   "Weight": 20,
                   "ServicePort": 80
                 }]
               }
           }]
    spec:
      ingressClassName: alb
      rules:
       - host: demo.domain.ingress.top
         http:
          paths:
          - path: /path
            pathType: Prefix
            backend:
              service:
                name: forward
                port:
                  name: use-annotation
  2. Access the service from the command line. For more information, see Access the service.

Scenario 2: Forward to cluster pods and external ECS

Prerequisites

Scenario

This scenario shows how to forward requests to both pods within a cluster and external ECS instances in the same VPC. You create a server group in the ALB console or by using the API, add the external ECS instance to it, and then reference its ServerGroupID in the Ingress annotation. This creates a hybrid backend, as shown in the following figure.

image

Procedure

  1. Configure the ALB Ingress.

    Deploy the following content to the tea-ingress.yaml file. This defines a service that forwards requests to both Pods within the cluster and ECS instances outside the cluster.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: tea-ingress
      annotations:
        alb.ingress.kubernetes.io/actions.forward: |
           [{
               "type": "ForwardGroup",
               "ForwardConfig": {
                 "ServerGroups" : [{
                   "ServiceName": "tea-svc",
                   "Weight": 30,
                   "ServicePort": 80
                 },
                 {
                   "ServiceName": "coffee-svc",
                   "Weight": 20,
                   "ServicePort": 80
                 },
                 {
                   "ServerGroupID": "sgp-71aexb9y93ypo*****",
                   "Weight": 30
                 },
                 {
                   "ServerGroupID": "sgp-slygpbvm2cydo*****",
                   "Weight": 20
                 }]
               }
           }]
    spec:
      ingressClassName: alb
      rules:
       - host: demo.domain.ingress.top
         http:
          paths:
          - path: /path
            pathType: Prefix
            backend:
              service:
                name: forward
                port:
                  name: use-annotation
  2. Access the service from the command line. For more information, see Access the service.

Scenario 3: Forward to cluster pods and cross-region ECS

Prerequisites

Scenario

This scenario demonstrates how to use CEN to establish a cross-region connection between VPCs. This lets you add an ECS instance from a different region to a server group. By referencing its ServerGroupID in the Ingress, you can route traffic to both in-cluster pods and the cross-region ECS instance, as shown in the following figures.

image

For example, an ACK or ACK Serverless cluster and an ALB instance are deployed in VPC1 in the China (Chengdu) region. You can use a combination of ALB and CEN to forward requests to an ECS instance in VPC2 in the China (Hangzhou) region.

image

Procedure

  1. Configure CEN and create a cross-region VPC connection.

    For more information, see Attach cross-region servers to an ALB instance.

    Note

    For ALB Ingress, you do not need to configure listeners for the ALB instance in the ALB console. You can configure listeners by using an ALB Ingress in Step 3.

  2. Add the cross-region ECS instance to the ALB server group.

    For more information, see Add or remove backend servers.

  3. Use the alb.ingress.kubernetes.io/actions.<service-name> annotation to configure a forwarding action and associate an existing server group. When a service is requested, this action forwards requests to Pods within the cluster and to ECS servers in a cross-region VPC outside the cluster.

    Deploy the following content to the tea-ingress.yaml file.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: tea-ingress
      annotations:
        alb.ingress.kubernetes.io/actions.forward: |
           [{
               "type": "ForwardGroup",
               "ForwardConfig": {
                 "ServerGroups" :  [{
                   "ServiceName": "tea-svc",
                   "Weight": 30,
                   "ServicePort": 80
                 },
                 {
                   "ServiceName": "coffee-svc",
                   "Weight": 20,
                   "ServicePort": 80
                 },
                 {
                   "ServerGroupID": "sgp-71aexb9y93ypo*****",
                   "Weight": 30
                 },
                 {
                   "ServerGroupID": "sgp-slygpbvm2cydo*****",
                   "Weight": 20
                 }]
               }
           }]
    spec:
      ingressClassName: alb
      rules:
       - host: demo.domain.ingress.top
         http:
          paths:
          - path: /path
            pathType: Prefix
            backend:
              service:
                name: forward
                port:
                  name: use-annotation

Scenario 4: Forward to cluster pods and on-premises servers

Prerequisites

Usage notes

For limitations on attaching on-premises servers to an ALB instance, see Limitations.

Scenario

This scenario shows how to use CEN, an Express Connect, and a VBR to connect your on-premises data center to Alibaba Cloud. This lets you add on-premises servers to a server group. By referencing the ServerGroupID in the Ingress, you can route traffic to both in-cluster pods and your on-premises servers, as shown in the following figures.

image

For example, an ACK or ACK Serverless cluster and an ALB instance are deployed in VPC1 in the China (Chengdu) region. You can use a combination of ALB, CEN, a VBR, and an Express Connect to forward requests to on-premises servers in the same region.

image

Procedure

  1. Configure CEN to connect the VPC where the ALB instance resides and the VBR to the transit router. This connects your on-premises data center to Alibaba Cloud through the VBR. For more information, see Attach on-premises servers in the same region to an ALB instance.

    Note

    For ALB Ingress, you do not need to configure listeners for the ALB instance in the ALB console. You can configure listeners by using an ALB Ingress in Step 2.

  2. Use the alb.ingress.kubernetes.io/actions.<service-name> annotation to configure a forwarding action and attach a specified, existing server group. This forwards requests to Pods within the cluster and to on-premises Internet Data Center (IDC) servers outside the cluster.

    Deploy the following content to the tea-ingress.yaml file.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: tea-ingress
      annotations:
        alb.ingress.kubernetes.io/actions.forward: |
           [{
               "type": "ForwardGroup",
               "ForwardConfig": {
                 "ServerGroups" :  [{
                   "ServiceName": "tea-svc",
                   "Weight": 30,
                   "ServicePort": 80
                 },
                 {
                   "ServiceName": "coffee-svc",
                   "Weight": 20,
                   "ServicePort": 80
                 },
                 {
                   "ServerGroupID": "sgp-ihydxb9y93ypo*****",
                   "Weight": 30
                 },
                 {
                   "ServerGroupID": "sgp-pd0ipbvm2cydo*****",
                   "Weight": 20
                 }]
               }
           }]
    spec:
      ingressClassName: alb
      rules:
       - host: demo.domain.ingress.top
         http:
          paths:
          - path: /path
            pathType: Prefix
            backend:
              service:
                name: forward
                port:
                  name: use-annotation