解除安裝叢內 Cloud Service Mesh

本頁面說明如何在使用 Istio API 時,解除安裝叢集內 Cloud Service Mesh。如果您使用 Compute Engine API,則無須採取任何步驟。如要瞭解兩者的差異,請參閱 Cloud Service Mesh 總覽。

按照這些操作說明解除安裝叢集內 Cloud Service Mesh 時,所有設定都會移除。

如要解除安裝代管 Cloud Service Mesh,請改用代管解除安裝指南。

如要從叢集內遷移至受管理,請改為按照遷移指南操作。

解除安裝 Cloud Service Mesh

使用下列指令解除安裝所有 Cloud Service Mesh 元件。

  1. 為避免中斷應用程式流量:

    • 將所有 STRICT mTLS 政策降級為 PERMISSIVE。
    • 移除可能封鎖流量的 AuthorizationPolicy。
  2. 如果已啟用,請在命名空間中停用 Sidecar 自動插入功能。執行下列指令,顯示命名空間標籤:

     kubectl get namespace YOUR_NAMESPACE --show-labels
    

    輸出結果會與下列內容相似:

     NAME   STATUS   AGE     LABELS
     demo   Active   4d17h   istio.io/rev=asm-181-5

    如果輸出內容的 LABELS 欄下方顯示 istio.io/rev=,請移除:

     kubectl label namespace YOUR_NAMESPACE istio.io/rev-
    

    如果輸出內容的 LABELS 欄下方顯示 istio-injection,請移除:

     kubectl label namespace YOUR_NAMESPACE istio-injection-
    

    如果沒有看到 istio.io/rev 或 istio-injection 標籤,表示命名空間未啟用自動插入功能。

  3. 重新啟動已插入 Sidecar 的工作負載,移除 Proxy。

  4. 從叢集刪除 validatingwebhooksconfiguration 和 mutatingwebhookconfiguration (如果有的話):

      kubectl delete validatingwebhookconfiguration,mutatingwebhookconfiguration -l operator.istio.io/component=Pilot,istio.io/owned-by!=mesh.googleapis.com
    
  5. 所有工作負載都啟動且未觀察到任何 Proxy 後,即可安全地刪除叢內控制層,停止計費。

    如要移除叢內控制平面,請執行下列指令:

    istioctl uninstall --purge
    

    如果沒有其他控制平面,您可以刪除命名空間,移除所有 Cloud Service Mesh 資源。istio-system否則,請刪除與 Cloud Service Mesh 修訂版本對應的服務。這樣可避免刪除共用資源,例如 CRD。

  6. (選用) 移除 Istio CR、Istio CRD、istio-(修訂版本) configmap、asm-options configmap、istio-system 和 asm-system 命名空間,從叢集中移除服務網格,或在其他與 Istio API 相容的服務網格中使用這些命名空間。

    1. 移除 Istio CR:

      kubectl delete gateways,virtualservices,destinationrules,serviceentries,envoyfilters,sidecars,peerauthentications,requestauthentications,authorizationpolicies,telemetries,wasmplugins,proxyconfigs --all --all-namespaces
      
    2. 移除 Istio CRD:

      kubectl get crds -o name | grep --color=never 'istio.io' | xargs kubectl delete
      
    3. 移除 istio-(修訂版本) configmap。如果刪除 istio-system 命名空間,可以略過這個步驟。

      kubectl delete configmap istio-RELEASE_CHANNEL -n istio-system
      

      將 RELEASE_CHANNEL 替換成發布管道

    4. 移除 istio-system 命名空間:

      kubectl delete namespace istio-system --ignore-not-found=true
      
    5. 移除 asm-system 命名空間:

      kubectl delete namespace asm-system --ignore-not-found=true
      
      1. 確認刪除作業是否成功:

         kubectl get ns
         ```
        
        The output should indicate a `Terminating` state and return as shown,
        otherwise you might have to manually delete any remaining resources in
        the namespaces and try again.
        
        ```sh
         NAME                 STATUS       AGE
         istio-system         Terminating  71m
         asm-system           Terminating  71m
         ```
        
  7. 如果您要刪除叢集或已刪除叢集,請確保每個叢集都已從機群取消註冊。

  8. 如要停止在機群層級使用 Cloud Service Mesh,請停用機群主專案的服務網格功能。

     gcloud container hub mesh disable --project FLEET_PROJECT_ID
    

    其中 FLEET_PROJECT_ID 是機群主機專案的 ID。

完成這些步驟後,系統會從叢集中移除所有 Cloud Service Mesh 元件,包括 Proxy、叢集內憑證授權單位,以及 RBAC 角色和繫結。在安裝過程中,系統會將必要權限授予 Google 擁有的服務帳戶,以便在叢集內建立服務網格資源。這些解除安裝指示不會撤銷權限,因此日後可以順利重新啟用 Cloud Service Mesh。