全部產品
Search
文件中心

Container Service for Kubernetes:多叢集服務概述

更新時間:Oct 19, 2025

ACK One多叢集服務可實現原生Service的跨叢集通訊,適用於因業務隔離、異地容災等需求部署多個叢集的情境。相較於傳統方案,多叢集服務無需部署額外Server Load Balancer執行個體,簡化了多叢集應用的部署操作和網路架構,同時降低了公網暴露的風險和相應的成本。

重要

多叢集服務跨叢集訪問要求叢集間容器網路互連,以確保一個叢集中的Pod可以直接存取另一個叢集的Pod,具體要求如下:

  • 多叢集處於不同VPC時,確保VPC位址區段不重疊,通過VPC對等串連雲企業網CEN(VPC跨地區時)實現VPC互聯。

  • 多叢集Pod位址區段和Service位址區段不重疊,並且叢集間節點池安全性群組相互允許存取Pod位址區段。

實現方案

ACK One提供了兩種多叢集服務實現方案:

  • MultiClusterService(推薦):配置方法簡單,無需修改業務代碼和DNS配置,可實現業務無侵入改造;使用原生Service網域名稱訪問。

  • ServiceImport/ServiceExport:符合社區API規範;使用專用網域名稱進行訪問,需修改DNS配置。

MultiClusterService

  1. Provider Cluster中已有應用Pod與service1,Consumer Cluster中的Pod需要訪問service1

  2. 在艦隊中建立MultiClusterService資源,指定Provider Cluster與Consumer Cluster。艦隊將根據Provider Cluster中的service1,在Consumer Cluster中自動建立同名的service1

    支援同時在spec.consumerClustersspec.providerClusters中配置多個叢集。
  3. Consumer Cluster中的Pod可以通過service1.<namespace>網域名稱直接存取Provider Cluster中的Pod。

使用MultiClusterService的具體操作,請參見使用原生Service網域名稱跨叢集服務訪問

ServiceImport/ServiceExport

  1. Provider Cluster中已有應用Pod與service1,Consumer Cluster中的Pod需要訪問service1

  2. 在Provider Cluster中建立ServiceExport資源,然後在Consumer Cluster中建立ServiceImport資源。

  3. 艦隊將確認ServiceExportServiceImport的配對,然後在Consumer Cluster中建立以amcs-為首碼的Service。

  4. 在Consumer Cluster中修改CoreDNS配置,使CoreDNS支援多叢集服務網域名稱解析。

  5. Consumer Cluster中的Pod可以通過以amcs-為首碼的Service訪問Provider Cluster中的Pod。

使用ServiceImport/ServiceExport的具體操作,請參見通過命令列管理多叢集服務

應用情境

跨叢集Service訪問

當業務部署在不同叢集且需要相互調用時,可使用多叢集服務功能。

  • 使用MultiClusterService:將Provider Cluster的叢集ID配置到providerClusters中,將Consumer Cluster的叢集ID配置到consumerClusters中:

    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:則在Provider Cluster中建立ServiceExport,在Consumer Cluster中建立ServiceImport。

基於多叢集的高可用服務

將多個叢集的同名Service作為高可用服務統一對外提供服務,請求會被均衡分配到多個叢集的多個Pod中,可實現關鍵業務的跨叢集級容災能力。

  • 使用MultiClusterService:將Provider Cluster 1和Provider Cluster 2的叢集ID都配置到providerClusters中,將Consumer Cluster的叢集ID配置到consumerClusters中:

    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:則在Provider Cluster 1和Provider Cluster 2中都建立ServiceExport,在Consumer Cluster中建立ServiceImport。