Multi-cluster service overview
Multi-cluster services (MCS) let pods in one Kubernetes cluster access Services running in another cluster. Compared with traditional approaches, MCS removes the need for extra load balancers, simplifies multi-cluster deployment and network architecture, and reduces public exposure risks and costs. Use MCS when you need to:
-
Isolate workloads across clusters while still sharing internal services
-
Deploy a Service across multiple clusters for high availability, cross-region disaster recovery, and cross-cluster load balancing
-
Connect clusters across separate VPCs without exposing Services through public endpoints
Implementation approaches
ACK One provides the following approaches to multi-cluster services:
-
MultiClusterService (recommended): Easy to configure. No changes to your application code or DNS configurations are required, and workloads do not need to be adapted. Native Service domain names are used for access.
-
ServiceImport/ServiceExport: Complies with the community API specification. Dedicated domain names are used for access, and you must modify the DNS configuration. For more information, see Manage multi-cluster services from the command line.
MultiClusterService
-
Application pods and a Service named
service1run in the provider cluster. A pod in the consumer cluster needs to accessservice1. -
Create a
MultiClusterServiceresource in the ACK One Fleet instance, and specify the provider cluster and the consumer cluster. Based onservice1in the provider cluster, the ACK One Fleet instance automatically creates a Service namedservice1in the consumer cluster.You can configure multiple clusters in
spec.consumerClustersandspec.providerClustersat the same time. -
The pod in the consumer cluster can directly access the pods in the provider cluster by using the
service1.<namespace>domain name.
For more information about how to use MultiClusterService, see Access Services across clusters by using domain names.
Key concepts
| Term | Description | Created by |
|---|---|---|
| ServiceExport | A custom resource you create in the provider cluster to expose a Service to other clusters. | User |
| ServiceImport | A custom resource representing a multi-cluster Service in the consumer cluster. | User |
| Clusterset | A group of clusters that share Services through MCS. Each cluster can act as a service provider, a service consumer, or both. | — |
| Service provider | The cluster that exports a Service by using ServiceExport. | Not applicable |
| Service consumer | The cluster that imports and accesses an exported Service by using ServiceImport. | Not applicable |
Architecture
The MCS feature relies on an ACK One Fleet instance to coordinate ServiceExport and ServiceImport objects across associated Container Service for Kubernetes (ACK) clusters.
Two connections are shown in the diagram:
-
Connection 1: the ACK One Fleet instance manages ServiceExport and ServiceImport in the associated ACK clusters. You create a ServiceExport in the provider cluster (ACK Cluster 1) and a ServiceImport in the consumer cluster (ACK Cluster 2).
-
Connection 2: data flows directly between clusters. After Service 1 is exported from ACK Cluster 1 and imported into ACK Cluster 2, pods in ACK Cluster 2 can reach Service 1.
How it works
The following diagram shows traffic flow across clusters.
-
Create a ServiceExport in ACK Cluster 1 (provider) and a ServiceImport in ACK Cluster 2 (consumer).
-
ACK One Fleet creates a Service named
amcs-<service-name>in ACK Cluster 2 and syncs the pod IP addresses from ACK Cluster 1 to its backend. -
Update the CoreDNS configuration in ACK Cluster 2 so that CoreDNS can resolve the domain names of multi-cluster Services.
-
Pods in ACK Cluster 2 can access Service 1 using either domain name format:
Format Example amcs-<service-name>.<provider-namespace>amcs-Service1.provider-ns<service-name>.<provider-namespace>.svc.clusterset.localService1.provider-ns.svc.clusterset.local
Use cases
Access a Service from a different cluster
Deploy your Service in ACK Cluster 1 and create a ServiceExport. Create a ServiceImport in ACK Cluster 2. Pods in ACK Cluster 2 can then access the Service through DNS. Traffic is load-balanced across the backend pods in ACK Cluster 1, and the pod count scales dynamically.
-
MultiClusterService: specify the cluster ID of the provider cluster in
providerClustersand the cluster ID of the consumer cluster inconsumerClusters:apiVersion: networking.one.alibabacloud.com/v1alpha1 kind: MultiClusterService metadata: name: service1 namespace: provider-ns spec: consumerClusters: - name: <Consumer Cluster ID> providerClusters: - name: <Provider Cluster ID> -
ServiceImport/ServiceExport: create a ServiceExport in the provider cluster and a ServiceImport in the consumer cluster.
Access a Service deployed across clusters
Deploy the same Service across multiple clusters for high availability. When a pod accesses the Service, traffic is balanced across pods in all participating clusters. This enables cross-cluster disaster recovery for critical services.
-
MultiClusterService: specify the cluster IDs of Provider Cluster 1 and Provider Cluster 2 in
providerClustersand the cluster ID of the consumer cluster inconsumerClusters:apiVersion: networking.one.alibabacloud.com/v1alpha1 kind: MultiClusterService metadata: name: service1 namespace: provider-ns spec: consumerClusters: - name: <Consumer Cluster ID> providerClusters: - name: <Provider Cluster 1 ID> - name: <Provider Cluster 2 ID> -
ServiceImport/ServiceExport: create a ServiceExport in Provider Cluster 1 and Provider Cluster 2, and create a ServiceImport in the consumer cluster.
Network requirements
Pod-to-pod traffic must flow directly between clusters for MCS to work. Before enabling MCS, verify that all three network requirements are met:
| Requirement | Why it matters |
|---|---|
| If multiple virtual private clouds (VPCs) are used, VPC CIDR blocks must not overlap, and the VPCs must be interconnected by using a VPC peering connection or, if the VPCs are in different regions, Cloud Enterprise Network (CEN). | Overlapping CIDR blocks cause routing conflicts; a VPC peering connection or CEN provides the cross-VPC network path. |
| Pod CIDR blocks must not overlap across clusters. Node pool security groups must mutually allow traffic between pod CIDR blocks. | Direct pod-to-pod routing requires unique addresses and open security group rules. |
| Pod CIDR blocks must not overlap with Service CIDR blocks in any cluster. | Overlapping pod and Service CIDR blocks break DNS-based Service discovery across clusters. |
For cluster-level network planning, see ACK managed cluster network planning.
Limitations
The Kubernetes version of all associated clusters must be 1.22 or later.