啟用及停用標準服務控制器

注意:Cloud Service Mesh 1.6.8 以上版本會自動支援 Canonical 服務。

使用 asmcli 安裝或升級 Cloud Service Mesh 時,系統會將 Canonical Service 控制器部署至叢集。標準服務控制器會將屬於相同邏輯服務的工作負載分組,並且必須在 Google Cloud 主控台的「服務」資訊主頁中提供完整功能。部署控制器會在 asm-system 命名空間的叢集中建立 canonical-service-controller-manager 部署,且不會影響您的服務或工作負載。

如果您未使用 asmcli 工具安裝 Cloud Service Mesh,叢集可能未啟用標準服務控制器。如要判斷叢集是否已啟用標準服務控制器,請按照下列步驟操作:

kubectl get services -n asm-system

啟用叢集內的 Canonical Service 控制器

如果未啟用標準服務控制器,您可以按照下列步驟進行啟用:

  1. 將包含控制器的 kpt 套件下載至目前的工作目錄:

    kpt pkg get https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages.git/asm@release-1.23 asm
    
  2. 套用控制器設定:

    kubectl apply -f asm/canonical-service/controller.yaml
    

停用叢集中的標準服務控制器

如要停用標準服務控制器,請按照下列步驟操作:

  1. 將包含控制器的 kpt 套件下載至目前的工作目錄:

    kpt pkg get https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages.git/asm@release-1.23 asm
    
  2. 從叢集中刪除控制器:

    kubectl delete -f asm/canonical-service/controller.yaml
    

啟用 Managed Canonical Service Controller

如果您不想安裝叢集內的控制器,可以改為啟用 Managed Canonical Service Controller,這樣系統就會為網格中的所有已註冊叢集執行相同的功能,而您不必自行安裝或管理控制器。

受管理的控制器旨在讓叢集內控制器產生。如果您要從叢集內控制器遷移,則必須從每個叢集中刪除叢集內控制器,讓受管理的控制器接管。詳情請參閱「停用叢集內的 Canonical Service 控制器」。

如要啟用受管理的控制器,請按照下列步驟操作:

建立 GKE 叢集

如果您在建立新的 GKE 叢集時使用「Enable Cloud Service Mesh」選項,系統會預設安裝 Managed Canonical Service Controller。

執行下列指令,確認您正在執行 Managed Canonical Service Controller:

gcloud beta container hub mesh describe --project=PROJECT_ID

說明指出標準服務已成功比對:

  projects/<your project number>/locations/global/memberships/<your cluster name>:
    code: OK
    description: |-
      Revision(s) ready for use: asm-managed.
      All Canonical Services have been reconciled successfully.
    servicemeshFeatureState: {}
    updateTime: '2021-11-16T21:10:36.289467777Z'

如果 Canonical 服務無法成功調和,系統會顯示錯誤訊息,或輸出類似以下的訊息:

  projects/<your project number>/locations/global/memberships/<your cluster name>:
    code: OK
    description: |-
      Revision(s) ready for use: istiod-asm-173-6.
      The Managed Canonical Service Controller is yielding to the in-cluster controller.  See https://cloud.google.com/service-mesh/v1.23/docs/canonical-service-controller-enable-and-disable#disable-in-cluster-service-controller for instructions on removing the in-cluster controller.
    servicemeshFeatureState: {}
    updateTime: '2021-11-16T21:05:43.286828851Z'
  lifecycleState: ENABLED

受管理的控制層安裝

如果您已安裝代管的 Cloud Service Mesh (使用 Fleet API 或 asmcli),則系統會預設安裝 Managed Canonical Service Controller。

執行下列指令,確認您正在執行 Managed Canonical Service Controller:

gcloud beta container hub mesh describe --project=PROJECT_ID

說明指出標準服務已成功比對:

  projects/<your project number>/locations/global/memberships/<your cluster name>:
    code: OK
    description: |-
      Revision(s) ready for use: asm-managed.
      All Canonical Services have been reconciled successfully.
    servicemeshFeatureState: {}
    updateTime: '2021-11-16T21:10:36.289467777Z'

如果 Canonical 服務無法成功調和,系統會顯示錯誤訊息,或輸出類似以下的訊息:

  projects/<your project number>/locations/global/memberships/<your cluster name>:
    code: OK
    description: |-
      Revision(s) ready for use: istiod-asm-173-6.
      The Managed Canonical Service Controller is yielding to the in-cluster controller.  See https://cloud.google.com/service-mesh/v1.23/docs/canonical-service-controller-enable-and-disable#disable-in-cluster-service-controller for instructions on removing the in-cluster controller.
    servicemeshFeatureState: {}
    updateTime: '2021-11-16T21:05:43.286828851Z'
  lifecycleState: ENABLED

後續步驟

瞭解下列內容: