使用 Helm 安裝

請按照本指南使用 Helm 安裝和設定 Istio 網格。

本指南中使用的 baseistiod 的 Helm 圖表與透過 Istioctl 安裝 Istio 時使用的相同。但是,透過 Istioctl 安裝會使用不同的 閘道圖表,而不是本指南中描述的 圖表

先決條件

  1. 執行任何必要的平台特定設定

  2. 檢查Pod 和服務的需求

  3. 安裝 Helm 用戶端,版本 3.6 或以上。

  4. 設定 Helm 儲存庫

$ helm repo add istio https://istio-release.storage.googleapis.com/charts
$ helm repo update

安裝步驟

本節說明使用 Helm 安裝 Istio 的程序。helm 安裝的一般語法是

$ helm install <release> <chart> --namespace <namespace> --create-namespace [--set <other_parameters>]

命令中指定的變數如下

  • <chart> 打包圖表的路徑、未打包圖表目錄的路徑或 URL。
  • <release> 安裝後用於識別和管理 Helm 圖表的名稱。
  • <namespace> 要在其中安裝圖表的命名空間。

可以使用一個或多個 --set <parameter>=<value> 參數變更預設組態值。或者,您可以使用 --values <file> 參數在自訂值檔案中指定多個參數。

  1. 為 Istio 元件建立命名空間 istio-system

    $ kubectl create namespace istio-system
    
  2. 安裝 Istio base 圖表,其中包含叢集範圍的自定義資源定義 (CRD),這些定義必須在部署 Istio 控制平面之前安裝。

    $ helm install istio-base istio/base -n istio-system --set defaultRevision=default
    
  3. 使用 helm ls 命令驗證 CRD 安裝。

    $ helm ls -n istio-system
    NAME       NAMESPACE    REVISION UPDATED                                 STATUS   CHART        APP VERSION
    istio-base istio-system 1        2024-04-17 22:14:45.964722028 +0000 UTC deployed base-1.24.0  1.24.0
    

    在輸出中找到 istio-base 的條目,並確保狀態設定為 deployed

  4. 如果您打算使用 Istio CNI 圖表,您現在必須這樣做。有關更多資訊,請參閱 使用 CNI 外掛程式安裝 Istio

  5. 安裝 Istio discovery 圖表,該圖表部署 istiod 服務。

    $ helm install istiod istio/istiod -n istio-system --wait
    
  6. 驗證 Istio discovery 圖表的安裝。

    $ helm ls -n istio-system
    NAME       NAMESPACE    REVISION UPDATED                                 STATUS   CHART         APP VERSION
    istio-base istio-system 1        2024-04-17 22:14:45.964722028 +0000 UTC deployed base-1.24.0   1.24.0
    istiod     istio-system 1        2024-04-17 22:14:45.964722028 +0000 UTC deployed istiod-1.24.0 1.24.0
    
  7. 取得已安裝的 Helm 圖表的狀態,以確保其已部署。

    $ helm status istiod -n istio-system
    NAME: istiod
    LAST DEPLOYED: Fri Jan 20 22:00:44 2023
    NAMESPACE: istio-system
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    NOTES:
    "istiod" successfully installed!
    
    To learn more about the release, try:
      $ helm status istiod
      $ helm get all istiod
    
    Next steps:
      * Deploy a Gateway: https://istio.dev.org.tw/latest/docs/setup/additional-setup/gateway/
      * Try out our tasks to get started on common configurations:
        * https://istio.dev.org.tw/latest/docs/tasks/traffic-management
        * https://istio.dev.org.tw/latest/docs/tasks/security/
        * https://istio.dev.org.tw/latest/docs/tasks/policy-enforcement/
        * https://istio.dev.org.tw/latest/docs/tasks/policy-enforcement/
      * Review the list of actively supported releases, CVE publications and our hardening guide:
        * https://istio.dev.org.tw/latest/docs/releases/supported-releases/
        * https://istio.dev.org.tw/latest/news/security/
        * https://istio.dev.org.tw/latest/docs/ops/best-practices/security/
    
    For further documentation see https://istio.dev.org.tw website
    
    Tell us how your install/upgrade experience went at https://forms.gle/99uiMML96AmsXY5d6
    
  8. 檢查 istiod 服務是否已成功安裝,並且其 Pod 正在執行。

    $ kubectl get deployments -n istio-system --output wide
    NAME     READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                         SELECTOR
    istiod   1/1     1            1           10m   discovery    docker.io/istio/pilot:1.24.0   istio=pilot
    
  9. (選用) 安裝一個 Ingress 閘道。

    $ kubectl create namespace istio-ingress
    $ helm install istio-ingress istio/gateway -n istio-ingress --wait
    

    有關閘道安裝的深入說明,請參閱 安裝閘道

更新 Istio 設定

您可以為上面使用的任何 Istio Helm 圖表提供特定的覆寫設定,並遵循 Helm 升級工作流程來自訂您的 Istio 網格安裝。可用的可設定選項可以使用 helm show values istio/<chart> 來找到;例如 helm show values istio/gateway

從非 Helm 安裝移轉

如果您要從使用 istioctl 安裝的 Istio 版本 (Istio 1.5 或更早版本) 遷移到 Helm,則需要刪除目前的 Istio 控制平面資源,並按照上述說明使用 Helm 重新安裝 Istio。刪除目前的 Istio 安裝時,您不得移除 Istio 自定義資源定義 (CRD),因為這可能會導致自定義 Istio 資源遺失。

您可以按照 Istioctl 解除安裝指南 中提到的步驟進行。

解除安裝

您可以通過解除安裝上面安裝的圖表來解除安裝 Istio 及其元件。

  1. 列出在 istio-system 命名空間中安裝的所有 Istio 圖表。

    $ helm ls -n istio-system
    NAME       NAMESPACE    REVISION UPDATED                                 STATUS   CHART         APP VERSION
    istio-base istio-system 1        2024-04-17 22:14:45.964722028 +0000 UTC deployed base-1.24.0   1.24.0
    istiod     istio-system 1        2024-04-17 22:14:45.964722028 +0000 UTC deployed istiod-1.24.0 1.24.0
    
  2. (選用) 刪除任何 Istio 閘道圖表安裝。

    $ helm delete istio-ingress -n istio-ingress
    $ kubectl delete namespace istio-ingress
    
  3. 刪除 Istio discovery 圖表。

    $ helm delete istiod -n istio-system
    
  4. 刪除 Istio base 圖表。

    $ helm delete istio-base -n istio-system
    
  5. 刪除 istio-system 命名空間。

    $ kubectl delete namespace istio-system
    

解除安裝穩定修訂標籤資源

如果您決定繼續使用舊的控制平面,而不是完成更新,您可以先發出 helm template istiod istio/istiod -s templates/revision-tags.yaml --set revisionTags={prod-canary} --set revision=canary -n istio-system | kubectl delete -f - 來解除安裝較新的版本及其標籤。然後,您必須按照上面的解除安裝程序來解除安裝它所指向的 Istio 版本。

如果您使用就地升級為此版本安裝了閘道,您還必須手動重新安裝先前版本的閘道。移除先前版本及其標籤不會自動還原先前升級的閘道。

(選用) 刪除由 Istio 安裝的 CRD

刪除 CRD 會永久移除您在叢集中建立的任何 Istio 資源。要刪除叢集中安裝的 Istio CRD

$ kubectl get crd -oname | grep --color=never 'istio.io' | xargs kubectl delete
這個資訊對您有幫助嗎?
您有任何改進建議嗎?

感謝您的回饋!