All Products
Search
Document Center

Container Service for Kubernetes:Work with multi-cluster Ingresses

Last Updated:May 12, 2025

Ingresses function as Layer-7 load balancers for Kubernetes clusters. Configured Ingress rules precisely route external requests to designated backend Services or applications. Through multi-cluster Services and Ingress rules, requests can be distributed across Services deployed in multiple clusters. This topic describes how to work with multi-cluster Ingresses.

Prerequisites

Usage notes

After configuring multi-cluster Services and Ingress rules, you can route requests to Services deployed across multiple clusters. The following figure shows the workflow:

image

In this example, Ingresses are created for ACK Cluster 1 and ACK Cluster 2. Applications are deployed in ACK Cluster 1, ACK Cluster 2, and ACK Cluster 3. The following figure shows how multi-cluster Ingresses are used to route requests.

image

Procedure

  1. Map a multi-cluster Service to the Services in the clusters that are configured with Ingresses.

    For more information about how to configure a multi-cluster Service, see Use the CLI to configure MCS.

    1. Configure a ServiceExport in each cluster to export the Service in the cluster to the multi-cluster Service.

    2. Configure a ServiceImport in each cluster that is configured with an Ingress. The ServiceImport is used to import the multi-cluster Service to the cluster so that the Ingress of the cluster can access the multi-cluster Service. By default, the imported Services are named in the amcs-{Service name} format.

    3. Run the following command in the clusters that are configured with Ingresses to query the imported Services:

      kubectl get service amcs-nginx
      NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE
      amcs-nginx   ClusterIP   192.168.118.171   <none>        80/TCP    34m
      
      kubectl get endpointslice
      NAME                                                     ADDRESSTYPE   PORTS   ENDPOINTS               AGE
      imported-c0c4a2c9339e44235a5228d0b0ff2259c-nginx-vnlnd   IPv4          80      10.0.2.4,10.0.2.5       34m
      imported-ce962c460ae284243a3161d6f2c7b4cf7-nginx-d8rr5   IPv4          80      10.0.2.221,10.0.2.236   29m
      imported-ca5b667538054499ab399588efe4ab654-nginx-xfe1a   IPv4          80      10.0.2.145,10.0.2.123   20m
  2. Configure Ingress rules in the clusters that are configured with Ingresses to expose Services.

    1. Create a file named ingress.yaml and copy the following content to the file:

      apiVersion: networking.k8s.io/v1
      kind: Ingress
      metadata:
        name: multi-cluster-nginx-ingress
      spec:
        rules:
        - host: example.com
          http:
            paths:
            - path: /
              pathType: Prefix
              backend:
                service:
                  name: amcs-nginx
                  port: 80
    2. Run the following command to configure Ingress rules in the clusters that are configured with Ingresses to route requests to the multi-cluster Service:

      kubectl apply -f ingress.yaml
    3. Query the Ingress endpoints of the clusters that are configured with Ingresses.

      # ACK Cluster 1
      kubectl get ingress
      NAME                          CLASS   HOSTS         ADDRESS         PORTS   AGE
      multi-cluster-nginx-ingress   nginx   example.com   XX.XX.XX.XX     80      26m
      
      # ACK Cluster 2
      kubectl get ingress
      NAME                          CLASS   HOSTS         ADDRESS         PORTS   AGE
      multi-cluster-nginx-ingress   nginx   example.com   XX.XX.XX.XX     80      26m
  3. Use DNS resolution to resolve the Ingress domain names.

    Create A records to resolve the Ingress domain names to the Ingress addresses of the clusters that are configured with Ingresses. For more information about domain name resolution, see Add DNS records.