將 Apigee Hybrid 升級至 1.6 版

如果您要從 Apigee hybrid 1.4 以下版本升級,請先升級至 hybrid 1.5 版,再升級至 1.6.9 版。請參閱將 Apigee Hybrid 升級至 1.5 版的操作說明。

升級至 1.6.9 版總覽。

升級 Apigee Hybrid 的程序分為以下幾個部分:

  1. 備份混合式安裝作業。
  2. 檢查 Kubernetes 版本,並視需要升級。
  3. 安裝 Hybrid 執行階段 1.6.9 版。
  4. 升級 ASM。

必修課程

這些升級操作說明假設您已安裝 Apigee hybrid 1.5,並希望將其升級至 1.6.9 版。如果您要從舊版更新,請參閱將 Apigee Hybrid 升級至 1.5 版的操作說明。

升級至 1.6 版

  1. 這些操作說明會使用環境變數 $APIGEECTL_HOME,用於指向安裝 apigeectl 公用程式的檔案系統目錄。如有需要,請將 cd 放入 apigeectl 目錄,然後使用下列指令定義變數:

    Linux

    export APIGEECTL_HOME=$PWD
    echo $APIGEECTL_HOME

    Mac OS

    export APIGEECTL_HOME=$PWD
    echo $APIGEECTL_HOME

    Windows

    set APIGEECTL_HOME=%CD%
    echo %APIGEECTL_HOME%
  2. (建議) 備份 1.5 版 $APIGEECTL_HOME/ 目錄。例如:
    tar -czvf $APIGEECTL_HOME/../apigeectl-v1.5-backup.tar.gz $APIGEECTL_HOME
  3. (建議) 按照「Cassandra 備份和復原」一文中的指示備份 Cassandra 資料庫
  4. 將 Kubernetes 平台升級至 hybrid 1.6 支援的版本。如需協助,請參閱平台的說明文件。
  5. 如果您執行的是 cert-manager 1.5.4 以下版本,請升級至 1.5.4 版本。
    1. 使用下列指令查看目前的 cert-manager 版本:

      kubectl -n cert-manager get deployment -o yaml | grep 'image:'
      

      系統會傳回類似以下的內容:

      image: quay.io/jetstack/cert-manager-controller:v1.5.4
      image: quay.io/jetstack/cert-manager-cainjector:v1.5.4
      image: quay.io/jetstack/cert-manager-webhook:v1.5.4
    2. 使用下列指令移除部署:
      $ kubectl delete -n cert-manager deployment cert-manager cert-manager-cainjector cert-manager-webhook
      
    3. 使用下列指令將 cert-manager 升級至 1.5.4 版:
      $ kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.4/cert-manager.yaml
      
  6. 建立 apigee-runtime 服務帳戶,以便與 Google OAUTH 權杖搭配使用。使用 create-service-account 工具:
    1. 建立服務帳戶:
      ./tools/create-service-account --env prod --profile apigee-runtime
    2. 將新的服務帳戶新增至 Apigee overrides.yaml 檔案:
      envs:
       - name: "environment-name"
         … … …
         serviceAccountPaths:
           runtime: "path-to-service-account-file"
         … … …
  7. 除了 envs 底下的項目之外,請在覆寫檔案的頂層新增 udca.serviceAccountPath 屬性。udca 必須在覆寫值中出現兩次,一次在環境層級,一次在機構層級,並與 connectAgentloggermartmetricswatcher 並行。

    例如:

    … … …
    
    metrics:
      serviceAccountPath: "metrics-service-account-file"
    
    udca:
      serviceAccountPath: "udca-service-account-file"
    
    watcher:
      serviceAccountPath: "watcher-service-account-file"
    … … …
  8. 選用步驟:如果您打算使用 Cloud Trace,請確認您的 apigee-runtime 服務帳戶具有 Cloud Trace 代理者 (roles/cloudtrace.agent) Google 角色。您可以前往 Cloud 控制台 > IAM 與管理員 > 服務帳戶 UI,或使用下列指令:
    1. 使用下列指令,取得 apigee-runtime 服務帳戶的電子郵件地址:
      gcloud iam service-accounts list --filter "apigee-runtime"

      如果符合模式 apigee-runtime@$ORG_NAME.iam.gserviceaccount.com,您可以在下一個步驟中使用該模式。

    2. Cloud Trace 代理人角色指派給服務帳戶:
      gcloud projects add-iam-policy-binding $PROJECT_ID \
          --member="serviceAccount:apigee-runtime@$PROJECT_ID.iam.gserviceaccount.com" \
          --role="roles/cloudtrace.agent"

      其中:$PROJECT_ID 是安裝 Apigee hybrid 的 Google Cloud 專案名稱。

安裝 Hybrid 1.6.9 執行階段

  1. 請確認您位於混合式基礎目錄 (apigeectl 可執行檔所在目錄的父目錄):
    cd $APIGEECTL_HOME/..
  2. 使用下列指令,下載適用於您作業系統的版本套件。請務必在下表中選取您的平台:

    Linux

    Linux 64 位元:

    curl -LO \
      https://storage.googleapis.com/apigee-release/hybrid/apigee-hybrid-setup/1.6.9/apigeectl_linux_64.tar.gz

    Mac OS

    Mac 64 位元:

    curl -LO \
      https://storage.googleapis.com/apigee-release/hybrid/apigee-hybrid-setup/1.6.9/apigeectl_mac_64.tar.gz

    Windows

    Windows 64 位元:

    curl -LO ^
      https://storage.googleapis.com/apigee-release/hybrid/apigee-hybrid-setup/1.6.9/apigeectl_windows_64.zip
  3. 將目前的 apigeectl/ 目錄重新命名為備份目錄名稱。例如:

    Linux

    mv $APIGEECTL_HOME/ $APIGEECTL_HOME-v1.5/

    Mac OS

    mv $APIGEECTL_HOME/ $APIGEECTL_HOME-v1.5/ 

    Windows

    rename %APIGEECTL_HOME% %APIGEECTL_HOME%-v1.5 
  4. 將下載的 gzip 檔案內容解壓縮至混合式基礎目錄。混合型基礎目錄是重新命名的 apigeectl-v1.5 目錄所在目錄:

    Linux

    tar xvzf filename.tar.gz -C ./

    Mac OS

    tar xvzf filename.tar.gz -C ./

    Windows

    tar xvzf filename.zip -C ./
  5. 根據預設,tar 內容會解壓縮為名稱中含有版本和平台的目錄。例如:./apigeectl_1.6.9-d591b23_linux_64。使用下列指令將該目錄重新命名為 apigeectl

    Linux

    mv directory-name-linux apigeectl

    Mac OS

    mv directory-name-mac apigeectl

    Windows

    rename directory-name-windows apigeectl
  6. 切換至 apigeectl 目錄:
    cd ./apigeectl

    apigeectl 可執行檔位於這個目錄中。

  7. 這些操作說明會使用環境變數 $APIGEECTL_HOME,用於指向安裝 apigeectl 公用程式的檔案系統目錄。如有需要,請將 cd 放入 apigeectl 目錄,然後使用下列指令定義變數:

    Linux

    export APIGEECTL_HOME=$PWD
    echo $APIGEECTL_HOME

    Mac OS

    export APIGEECTL_HOME=$PWD
    echo $APIGEECTL_HOME

    Windows

    set APIGEECTL_HOME=%CD%
    echo %APIGEECTL_HOME%
  8. 使用 version 指令驗證 apigeectl 的版本:
    ./apigeectl version
    Version: 1.6.9
  9. 移至 hybrid-base-directory/hybrid-files 目錄。hybrid-files 目錄是設定檔的所在位置,例如覆寫檔案、憑證和服務帳戶。例如:
    cd $APIGEECTL_HOME/../hybrid-files
  10. 使用下列指令,確認 kubectl 已設為正確的內容。目前的內容應設為您要升級 Apigee Hybrid 的叢集。
    kubectl config get-contexts | grep \*
  11. hybrid-files 目錄中:
    1. 將下列符號連結更新為 $APIGEECTL_HOME。這些連結可讓您從 hybrid-files 目錄內執行新安裝的 apigeectl 指令:
      ln -nfs $APIGEECTL_HOME/tools tools
      ln -nfs $APIGEECTL_HOME/config config
      ln -nfs $APIGEECTL_HOME/templates templates
      ln -nfs $APIGEECTL_HOME/plugins plugins
    2. 如要確認符號連結是否正確建立,請執行下列指令,並確認連結路徑指向正確位置:
      ls -l | grep ^l
    3. 執行初始化模擬測試,檢查是否有錯誤:
      ${APIGEECTL_HOME}/apigeectl init -f ./overrides/OVERRIDES.yaml --dry-run=client

      其中 OVERRIDES 是覆寫檔案的名稱。

    4. 如果沒有任何錯誤,請初始化 hybrid 1.6.9:
      ${APIGEECTL_HOME}/apigeectl init -f ./overrides/OVERRIDES.yaml
    5. 檢查初始化狀態:
      ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml
    6. 執行 apply 指令的模擬測試,檢查是否有錯誤:
      ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --dry-run=client
    7. 如果沒有任何錯誤,請套用覆寫值。請根據安裝方式,選取並遵循實際工作環境或示範/實驗環境的操作說明。

      生產

      在實際環境中,您應個別升級每個混合型元件,並在繼續升級其他元件前,先檢查已升級元件的狀態。

      1. 確認您位於 hybrid-files 目錄。
      2. 套用覆寫值來升級 Cassandra:
        ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --datastore
      3. 檢查完成情況:
        ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml

        只有在 Pod 就緒時,才繼續執行下一個步驟。

      4. 套用覆寫值來升級遙測元件,並檢查完成情況:
        ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --telemetry
        ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml
      5. 啟動 Redis 元件:
        ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --redis
      6. 套用覆寫值來升級機構層級元件 (MART、Watcher 和 Apigee Connect),並檢查完成情況:
        ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --org
        ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml
      7. 套用覆寫值來升級環境。您有兩種選擇:
        • 逐一環境:一次將覆寫值套用至一個環境,並檢查是否完成。針對每個環境重複執行這個步驟:
          ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --env ENV_NAME
          ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml

          其中 ENV_NAME 是您要升級的環境名稱。

        • 一次套用至所有環境:一次將覆寫值套用至所有環境,並檢查完成情況:
          ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml --all-envs
          ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml

      示範/實驗

      在大多數的示範或實驗環境中,您可以一次將覆寫值套用至所有元件。如果您的示範/實驗環境龐大且複雜,或與實際執行環境相似,建議您參考升級實際執行環境的操作說明

      1. 確認您位於 hybrid-files 目錄。
      2. ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/OVERRIDES.yaml
      3. 查看狀態:
        ${APIGEECTL_HOME}/apigeectl check-ready -f ./overrides/OVERRIDES.yaml

將 ASM 升級至 版

請按照適用於您平台的 ASM 說明文件執行升級作業:

安裝及設定 ASM 的操作說明會因平台而異。平台分為下列類別:

  • GKE:在 Google Cloud 上執行的 Google Kubernetes Engine 叢集。
  • Google Cloud 以外:在下列系統上執行的 Anthos 叢集:
    • VMware 中的 Anthos 叢集 (GKE On-Prem)
    • 裸機中的 Anthos
    • AWS 中的 Anthos 叢集
    • Amazon EKS
  • 其他 Kubernetes 平台:在下列系統上建立及執行符合標準的叢集:
    • AKS
    • EKS
    • OpenShift

GKE

混合式安裝升級至 ASM 版本 的程序如下:

  1. 準備升級。
  2. 安裝新版的 ASM。
  3. 從目前的已安裝項目中刪除先前 ASM 版本的部署、服務和 webhook。
  4. 升級閘道並設定新的 webhook。

如要將 GKE 上的混合式升級至 ASM 版本,請按照以下步驟操作:

一文中的操作說明操作。
  1. 查看「升級 Anthos 服務網格」中的相關規定,但暫時不要執行升級作業。
  2. 在安裝新版本前,請先確認目前的修訂版本。您需要這項資訊,才能從目前的環境中刪除先前 ASM 版本的部署作業、服務和 webhook。請使用下列指令,將目前的 istiod 修訂版本儲存至環境變數:
    export DELETE_REV=$(kubectl get deploy -n istio-system -l app=istiod -o jsonpath={.items[].metadata.labels.'istio\.io\/rev'}'{"\n"}')
    echo ${DELETE_REV}
  3. 建立新的 overlay.yaml 檔案,或確認現有的 overlay.yaml 包含下列內容:
    apiVersion: install.istio.io/v1alpha1
    kind: IstioOperator
    spec:
      revision: 
      components:
        ingressGateways:
          - name: istio-ingressgateway
            enabled: true
            k8s:
              nodeSelector:
                # default node selector, if different or not using node selectors, change accordingly.
                cloud.google.com/gke-nodepool: apigee-runtime
              resources:
                requests:
                  cpu: 1000m
              service:
                type: LoadBalancer
                loadBalancerIP: STATIC_IP # If you do not have a reserved static IP, leave this out.
                ports:
                  - name: http-status-port
                    port: 15021
                  - name: http2
                    port: 80
                    targetPort: 8080
                  - name: https
                    port: 443
                    targetPort: 8443
      meshConfig:
        accessLogFormat:
          '{"start_time":"%START_TIME%","remote_address":"%DOWNSTREAM_DIRECT_REMOTE_ADDRESS%","user_agent":"%REQ(USER-AGENT)%","host":"%REQ(:AUTHORITY)%","request":"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%","request_time":"%DURATION%","status":"%RESPONSE_CODE%","status_details":"%RESPONSE_CODE_DETAILS%","bytes_received":"%BYTES_RECEIVED%","bytes_sent":"%BYTES_SENT%","upstream_address":"%UPSTREAM_HOST%","upstream_response_flags":"%RESPONSE_FLAGS%","upstream_response_time":"%RESPONSE_DURATION%","upstream_service_time":"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%","upstream_cluster":"%UPSTREAM_CLUSTER%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","request_method":"%REQ(:METHOD)%","request_path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","request_protocol":"%PROTOCOL%","tls_protocol":"%DOWNSTREAM_TLS_VERSION%","request_id":"%REQ(X-REQUEST-ID)%","sni_host":"%REQUESTED_SERVER_NAME%","apigee_dynamic_data":"%DYNAMIC_METADATA(envoy.lua)%"}'
  4. 請按照 ASM 說明文件中以下各節的操作說明進行:
    1. 下載 asmcli
    2. 授予叢集管理員權限
    3. 驗證專案和叢集
    4. 升級至含選用功能的方案。在開始「升級網關」部分前先停下
  5. 刪除變異 Webhook 和驗證 Webhook:
    1. cd 至安裝 asmcli 的目錄。
    2. 將目前的新修訂版本儲存在環境變數中,以便在刪除 webhook 時使用:
      UPGRADE_REV=""
    3. 建立包含下列指令的指令稿:
      #!/bin/bash
      
      set -ex
      
      PROJECT_ID="YOUR_PROJECT_ID"
      CLUSTER_NAME="YOUR_CLUSTER_NAME"
      CLUSTER_LOCATION="YOUR_CLUSTER_LOCATION"
      
      kubectl label namespace istio-system istio.io/rev=${UPGRADE_REV} istio-injection- --overwrite
      kubectl rollout restart deployment -n istio-system
      kubectl apply -n istio-system -f PATH_TO_INGRESSGATEWAYistio-ingressgateway
      kubectl apply -n istio-system -f PATH_TO_INGRESSGATEWAY/istio-ingressgateway-connectors
      
      if [[ "${DELETE_REV}" != "${UPGRADE_REV}" ]]; then
        kubectl apply -f out/asm/istio/istiod-service.yaml
        kubectl delete deploy -l app=istio-ingressgateway,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete deploy -l app=istio-ingressgateway-connectors,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete ValidatingWebhookConfiguration -l app=istiod,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete MutatingWebhookConfiguration -l app=sidecar-injector,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete Service,Deployment,HorizontalPodAutoscaler,PodDisruptionBudget istiod-${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete IstioOperator installed-state-${DELETE_REV} -n istio-system --ignore-not-found=true
      fi
      
    4. 執行指令碼,刪除目前的 webhook。
  6. 請按照「升級閘道」中的步驟建立新的 webhook,並將流量切換至新的閘道。

Google Cloud 以外

這些操作說明涵蓋以下項目的 ASM 升級作業:

  • VMware 中的 Anthos 叢集 (GKE On-Prem)
  • 裸機中的 Anthos
  • AWS 中的 Anthos 叢集
  • Amazon EKS
中的操作說明進行。

混合式安裝升級至 ASM 版本 的程序如下:

  1. 準備升級。
  2. 安裝新版的 ASM。
  3. 從目前的裝置中刪除異動 Webhook 和驗證 Webhook。
  4. 升級閘道並設定新的 webhook。
  1. 查看「升級 Anthos 服務網格」中的相關規定,但暫時不要執行升級作業。
  2. 在安裝新版本前,請先確認目前的修訂版本。您需要這項資訊才能從目前的 ASM 安裝項目中刪除驗證 webhook變異 webhook。請使用下列指令,將目前的 istiod 修訂版本儲存至環境變數:
    export DELETE_REV=$(kubectl get deploy -n istio-system -l app=istiod -o jsonpath={.items[].metadata.labels.'istio\.io\/rev'}'{"\n"}')
    echo ${DELETE_REV}
  3. 建立新的 overlay.yaml 檔案,或確認現有的 overlay.yaml 包含下列內容:
    apiVersion: install.istio.io/v1alpha1
    kind: IstioOperator
    spec:
      revision: 
      components:
        ingressGateways:
          - name: istio-ingressgateway
            enabled: true
            k8s:
              nodeSelector:
                # default node selector, if different or not using node selectors, change accordingly.
                cloud.google.com/gke-nodepool: apigee-runtime
              resources:
                requests:
                  cpu: 1000m
              service:
                type: LoadBalancer
                loadBalancerIP: STATIC_IP # If you do not have a reserved static IP, leave this out.
                ports:
                  - name: http-status-port
                    port: 15021
                  - name: http2
                    port: 80
                    targetPort: 8080
                  - name: https
                    port: 443
                    targetPort: 8443
      values:
        gateways:
          istio-ingressgateway:
            runAsRoot: true
    
      meshConfig:
        accessLogFormat:
          '{"start_time":"%START_TIME%","remote_address":"%DOWNSTREAM_DIRECT_REMOTE_ADDRESS%","user_agent":"%REQ(USER-AGENT)%","host":"%REQ(:AUTHORITY)%","request":"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%","request_time":"%DURATION%","status":"%RESPONSE_CODE%","status_details":"%RESPONSE_CODE_DETAILS%","bytes_received":"%BYTES_RECEIVED%","bytes_sent":"%BYTES_SENT%","upstream_address":"%UPSTREAM_HOST%","upstream_response_flags":"%RESPONSE_FLAGS%","upstream_response_time":"%RESPONSE_DURATION%","upstream_service_time":"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%","upstream_cluster":"%UPSTREAM_CLUSTER%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","request_method":"%REQ(:METHOD)%","request_path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","request_protocol":"%PROTOCOL%","tls_protocol":"%DOWNSTREAM_TLS_VERSION%","request_id":"%REQ(X-REQUEST-ID)%","sni_host":"%REQUESTED_SERVER_NAME%","apigee_dynamic_data":"%DYNAMIC_METADATA(envoy.lua)%"}'
  4. 請按照 ASM 說明文件中以下各節的操作說明進行:
    1. 下載 asmcli
    2. 授予叢集管理員權限
    3. 驗證專案和叢集
    4. 升級至含選用功能的方案。在開始「升級網關」部分前先停下
  5. 刪除變異 Webhook 和驗證 Webhook:
    1. cd 至安裝 asmcli 的目錄。
    2. 將目前的新修訂版本儲存在環境變數中,以便在刪除 webhook 時使用:
      UPGRADE_REV=""
    3. 建立包含下列指令的指令稿:
      #!/bin/bash
      
      set -ex
      
      PROJECT_ID="YOUR_PROJECT_ID"
      CLUSTER_NAME="YOUR_CLUSTER_NAME"
      CLUSTER_LOCATION="YOUR_CLUSTER_LOCATION"
      
      
      gcloud config configurations activate ${PROJECT_ID}
      gcloud container clusters get-credentials ${CLUSTER_NAME} --region ${CLUSTER_LOCATION} --project ${PROJECT_ID}
      
      
      kubectl label namespace istio-system istio.io/rev=${UPGRADE_REV} istio-injection- --overwrite
      kubectl rollout restart deployment -n istio-system
      kubectl apply -n istio-system -f PATH_TO_INGRESSGATEWAYistio-ingressgateway
      kubectl apply -n istio-system -f PATH_TO_INGRESSGATEWAY/istio-ingressgateway-connectors
      
      if [[ "${DELETE_REV}" != "${UPGRADE_REV}" ]]; then
        kubectl apply -f out/asm/istio/istiod-service.yaml
        kubectl delete deploy -l app=istio-ingressgateway,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete deploy -l app=istio-ingressgateway-connectors,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete ValidatingWebhookConfiguration -l app=istiod,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete MutatingWebhookConfiguration -l app=sidecar-injector,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete Service,Deployment,HorizontalPodAutoscaler,PodDisruptionBudget istiod-${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete IstioOperator installed-state-${DELETE_REV} -n istio-system --ignore-not-found=true
      fi
      
    4. 執行指令碼,刪除目前的 webhook。
  6. 請按照「升級閘道」中的步驟建立新的 webhook,並將流量切換至新的閘道。

AKS / EKS

在這些操作說明中,在 Anthos 已連結叢集中升級 Anthos 服務網格 (ASM) 版本的程序,與執行全新安裝程序相同。

準備安裝 Anthos 服務網格

  1. 刪除變異 Webhook 和驗證 Webhook:
    1. cd 至安裝 asmcli 的目錄。
    2. 將目前的新修訂版本儲存在環境變數中,以便在刪除 webhook 時使用:
      UPGRADE_REV=""
    3. 建立包含下列指令的 Shell 指令碼:
      #!/bin/bash
      
      set -ex
      
      kubectl label namespace istio-system istio.io/rev=${UPGRADE_REV} istio-injection- --overwrite
      kubectl rollout restart deployment -n istio-system
      
      if [[ "${DELETE_REV}" != "${UPGRADE_REV}" ]]; then
        kubectl apply -f out/asm/istio/istiod-service.yaml
        kubectl apply -f ASMCLI_OUTPUT_DIR/asm/istio/istiod-service.yaml ASMCLI_OUTPUT_DIR/istioctl tag set default --revision ${UPGRADE_REV}
      
      
        kubectl delete deploy -l app=istio-ingressgateway,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete ValidatingWebhookConfiguration -l app=istiod,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete MutatingWebhookConfiguration -l app=sidecar-injector,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete Service,Deployment,HorizontalPodAutoscaler,PodDisruptionBudget istiod-${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete IstioOperator installed-state-${DELETE_REV} -n istio-system --ignore-not-found=true
      fi
      
    4. 執行指令碼,刪除目前的 webhook。
  2. Linux

  3. 將 Anthos 服務網格安裝檔案下載至目前的工作目錄:
    curl -LO https://storage.googleapis.com/gke-release/asm/-linux-amd64.tar.gz
  4. 下載簽章檔案,然後使用 openssl 驗證簽章:
    curl -LO https://storage.googleapis.com/gke-release/asm/-linux-amd64.tar.gz.1.sig
    openssl dgst -verify /dev/stdin -signature -linux-amd64.tar.gz.1.sig .tar.gz <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF
  5. 將檔案的內容解壓縮到您檔案系統上的任何位置,例如,如要將內容擷取至目前的工作目錄:
    tar xzf -linux-amd64.tar.gz

    這個指令會在目前工作目錄中建立名為 的安裝目錄,其中包含:

    • samples 目錄中的範例應用程式。
    • 用來安裝 Anthos 服務網格的 istioctl 指令列工具位於 bin 目錄中。
    • Anthos 服務網格設定檔位於 manifests/profiles 目錄中。
  6. 請確認您位於 Anthos 服務網格安裝的根目錄中:
    cd 
  7. 為方便起見,請將 /bin 目錄中的工具新增至 PATH:
    export PATH=$PWD/bin:$PATH
  8. Mac OS

  9. 將 Anthos 服務網格安裝檔案下載至目前的工作目錄:
    curl -LO https://storage.googleapis.com/gke-release/asm/-osx.tar.gz
  10. 下載簽章檔案,然後使用 openssl 驗證簽章:
    curl -LO https://storage.googleapis.com/gke-release/asm/-osx.tar.gz.1.sig
    openssl dgst -sha256 -verify /dev/stdin -signature -osx.tar.gz.1.sig .tar.gz <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF
  11. 將檔案的內容解壓縮到您檔案系統上的任何位置,例如,如要將內容擷取至目前的工作目錄:
    tar xzf -osx.tar.gz

    這個指令會在目前工作目錄中建立名為 的安裝目錄,其中包含:

    • samples 目錄中的範例應用程式。
    • 用來安裝 Anthos 服務網格的 istioctl 指令列工具位於 bin 目錄中。
    • Anthos 服務網格設定檔位於 manifests/profiles 目錄中。
  12. 請確認您位於 Anthos 服務網格安裝的根目錄中:
    cd 
  13. 為方便起見,請將 /bin 目錄中的工具新增至 PATH:
    export PATH=$PWD/bin:$PATH
  14. Windows

  15. 將 Anthos 服務網格安裝檔案下載至目前的工作目錄:
    curl -LO https://storage.googleapis.com/gke-release/asm/-win.zip
  16. 下載簽章檔案,然後使用 openssl 驗證簽章:
    curl -LO https://storage.googleapis.com/gke-release/asm/-win.zip.1.sig
    openssl dgst -verify - -signature -win.zip.1.sig .win.zip <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF
  17. 將檔案的內容解壓縮到您檔案系統上的任何位置,例如,如要將內容擷取至目前的工作目錄:
    tar xzf -win.zip

    這個指令會在目前工作目錄中建立名為 的安裝目錄,其中包含:

    • samples 目錄中的範例應用程式。
    • 用來安裝 Anthos 服務網格的 istioctl 指令列工具位於 bin 目錄中。
    • Anthos 服務網格設定檔位於 manifests\profiles 目錄中。
  18. 請確認您位於 Anthos 服務網格安裝的根目錄中:
    cd 
  19. 為方便起見,請將 \bin 目錄中的工具新增至 PATH:
    set PATH=%CD%\bin:%PATH%
  20. 安裝 ASM Istio 後,請檢查 istioctl 的版本:
    istioctl version
  21. 為控制平面元件建立名為 istio-system 的命名空間:
    kubectl create namespace istio-system

安裝 Anthos 服務網格

  1. 編輯 overlay.yaml 檔案或建立新的檔案,並加入以下內容:
    apiVersion: install.istio.io/v1alpha1
    kind: IstioOperator
    spec:
      meshConfig:
        accessLogFile: /dev/stdout
        enableTracing: true
        accessLogFormat:
          '{"start_time":"%START_TIME%","remote_address":"%DOWNSTREAM_DIRECT_REMOTE_ADDRESS%","user_agent":"%REQ(USER-AGENT)%","host":"%REQ(:AUTHORITY)%","request":"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%","request_time":"%DURATION%","status":"%RESPONSE_CODE%","status_details":"%RESPONSE_CODE_DETAILS%","bytes_received":"%BYTES_RECEIVED%","bytes_sent":"%BYTES_SENT%","upstream_address":"%UPSTREAM_HOST%","upstream_response_flags":"%RESPONSE_FLAGS%","upstream_response_time":"%RESPONSE_DURATION%","upstream_service_time":"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%","upstream_cluster":"%UPSTREAM_CLUSTER%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","request_method":"%REQ(:METHOD)%","request_path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","request_protocol":"%PROTOCOL%","tls_protocol":"%DOWNSTREAM_TLS_VERSION%","request_id":"%REQ(X-REQUEST-ID)%","sni_host":"%REQUESTED_SERVER_NAME%","apigee_dynamic_data":"%DYNAMIC_METADATA(envoy.lua)%"}'
      components:
      - enabled: true
        name: istio-ingressgateway
        k8s:
          service:
            type: LoadBalancer
            ports:
            - name: status-port
              port: 15021
              targetPort: 15021
            - name: http2
              port: 80
              targetPort: 8080
            - name: https
              port: 443
              targetPort: 8443
    
  2. 使用 asm-multicloud 設定檔,透過 istioctl 安裝 Anthos 服務網格:
    istioctl install \
        --set profile=asm-multicloud \
        --set revision="" \
        --filename overlayfile.yaml

    輸出內容應如下所示:

    kubectl get pods -n istio-system
    NAME                                   READY   STATUS    RESTARTS   AGE
    istio-ingressgateway-88b6fd976-flgp2   1/1     Running   0          3m13s
    istio-ingressgateway-88b6fd976-p5dl9   1/1     Running   0          2m57s
    istiod--798ffb964-2ls88       1/1     Running   0          3m21s
    istiod--798ffb964-fnj8c       1/1     Running   1          3m21s

    --set revision 引數會將以 istio.io/rev= 格式編寫的修訂版本標籤新增至 istiod。自動附加元件注入器 webhook 會使用修訂版本標籤,將注入的附加元件與特定 istiod 修訂版本建立關聯。如要為命名空間啟用自動補充插入功能,您必須使用與 istiod 上的標籤相符的修訂版本標記命名空間。

  3. 確認安裝作業已完成:
    kubectl get svc -n istio-system

    輸出內容應如下所示:

    NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                                                                      AGE
    istio-ingressgateway   LoadBalancer   172.200.48.52    34.74.177.168   15021:30479/TCP,80:30030/TCP,443:32200/TCP,15012:32297/TCP,15443:30244/TCP   3m35s
    istiod                 ClusterIP      172.200.18.133   <none>          15010/TCP,15012/TCP,443/TCP,15014/TCP                                        4m46s
    istiod-       ClusterIP      172.200.63.220   <none>          15010/TCP,15012/TCP,443/TCP,15014/TCP                                        3m43s

OpenShift

在這些操作說明中,在 Anthos 已連結叢集中升級 Anthos 服務網格 (ASM) 版本的程序,與執行全新安裝程序相同。

準備安裝 Anthos 服務網格

  1. 刪除變異 Webhook 和驗證 Webhook:
    1. cd 至安裝 asmcli 的目錄。
    2. 將目前的新修訂版本儲存在環境變數中,以便在刪除 webhook 時使用:
      UPGRADE_REV=""
    3. 建立包含下列指令的 Shell 指令碼:
      #!/bin/bash
      
      set -ex
      
      kubectl label namespace istio-system istio.io/rev=${UPGRADE_REV} istio-injection- --overwrite
      kubectl rollout restart deployment -n istio-system
      kubectl apply -n istio-system -f PATH_TO_INGRESSGATEWAYistio-ingressgateway
      
      if [[ "${DELETE_REV}" != "${UPGRADE_REV}" ]]; then
        kubectl apply -f out/asm/istio/istiod-service.yaml
        kubectl delete deploy -l app=istio-ingressgateway,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete deploy -l app=istio-ingressgateway-connectors,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete ValidatingWebhookConfiguration -l app=istiod,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete MutatingWebhookConfiguration -l app=sidecar-injector,istio.io/rev=${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete Service,Deployment,HorizontalPodAutoscaler,PodDisruptionBudget istiod-${DELETE_REV} -n istio-system --ignore-not-found=true
        kubectl delete IstioOperator installed-state-${DELETE_REV} -n istio-system --ignore-not-found=true
      fi
      
    4. 執行指令碼,刪除目前的 webhook。
  2. Linux

  3. 使用下列 OpenShift CLI (oc) 指令,將 anyuid 安全性內容限制 (SCC) 授予 istio-system:
    oc adm policy add-scc-to-group anyuid system:serviceaccounts:istio-system
  4. 將 Anthos 服務網格安裝檔案下載至目前的工作目錄:
    curl -LO https://storage.googleapis.com/gke-release/asm/-linux-amd64.tar.gz
  5. 下載簽章檔案,然後使用 openssl 驗證簽章:
    curl -LO https://storage.googleapis.com/gke-release/asm/-linux-amd64.tar.gz.1.sig
    openssl dgst -verify /dev/stdin -signature -linux-amd64.tar.gz.1.sig .tar.gz <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF
  6. 將檔案的內容解壓縮到您檔案系統上的任何位置,例如,如要將內容擷取至目前的工作目錄:
    tar xzf -linux-amd64.tar.gz

    這個指令會在目前工作目錄中建立名為 的安裝目錄,其中包含:

    • samples 目錄中的範例應用程式。
    • 用來安裝 Anthos 服務網格的 istioctl 指令列工具位於 bin 目錄中。
    • Anthos 服務網格設定檔位於 manifests/profiles 目錄中。
  7. 請確認您位於 Anthos 服務網格安裝的根目錄中:
    cd 
  8. 為方便起見,請將 /bin 目錄中的工具新增至 PATH:
    export PATH=$PWD/bin:$PATH
  9. Mac OS

  10. 使用下列 OpenShift CLI (oc) 指令,將 anyuid 安全性內容限制 (SCC) 授予 istio-system:
    oc adm policy add-scc-to-group anyuid system:serviceaccounts:istio-system
  11. 將 Anthos 服務網格安裝檔案下載至目前的工作目錄:
    curl -LO https://storage.googleapis.com/gke-release/asm/-osx.tar.gz
  12. 下載簽章檔案,然後使用 openssl 驗證簽章:
    curl -LO https://storage.googleapis.com/gke-release/asm/-osx.tar.gz.1.sig
    openssl dgst -sha256 -verify /dev/stdin -signature -osx.tar.gz.1.sig .tar.gz <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF
  13. 將檔案的內容解壓縮到您檔案系統上的任何位置,例如,如要將內容擷取至目前的工作目錄:
    tar xzf -osx.tar.gz

    這個指令會在目前工作目錄中建立名為 的安裝目錄,其中包含:

    • samples 目錄中的範例應用程式。
    • 用來安裝 Anthos 服務網格的 istioctl 指令列工具位於 bin 目錄中。
    • Anthos 服務網格設定檔位於 manifests/profiles 目錄中。
  14. 請確認您位於 Anthos 服務網格安裝的根目錄中:
    cd 
  15. 為方便起見,請將 /bin 目錄中的工具新增至 PATH:
    export PATH=$PWD/bin:$PATH
  16. Windows

  17. 使用下列 OpenShift CLI (oc) 指令,將 anyuid 安全性內容限制 (SCC) 授予 istio-system:
    oc adm policy add-scc-to-group anyuid system:serviceaccounts:istio-system
  18. 將 Anthos 服務網格安裝檔案下載至目前的工作目錄:
    curl -LO https://storage.googleapis.com/gke-release/asm/-win.zip
  19. 下載簽章檔案,然後使用 openssl 驗證簽章:
    curl -LO https://storage.googleapis.com/gke-release/asm/-win.zip.1.sig
    openssl dgst -verify - -signature -win.zip.1.sig .win.zip <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF
  20. 將檔案的內容解壓縮到您檔案系統上的任何位置,例如,如要將內容擷取至目前的工作目錄:
    tar xzf -win.zip

    這個指令會在目前工作目錄中建立名為 的安裝目錄,其中包含:

    • samples 目錄中的範例應用程式。
    • 用來安裝 Anthos 服務網格的 istioctl 指令列工具位於 bin 目錄中。
    • Anthos 服務網格設定檔位於 manifests\profiles 目錄中。
  21. 請確認您位於 Anthos 服務網格安裝的根目錄中:
    cd 
  22. 為方便起見,請將 \bin 目錄中的工具新增至 PATH:
    set PATH=%CD%\bin:%PATH%
  23. 安裝 ASM Istio 後,請檢查 istioctl 的版本:
    istioctl version
  24. 為控制平面元件建立名為 istio-system 的命名空間:
    kubectl create namespace istio-system

安裝 Anthos 服務網格

  1. 編輯 overlay.yaml 檔案或建立新的檔案,並加入以下內容:
    apiVersion: install.istio.io/v1alpha1
    kind: IstioOperator
    spec:
      meshConfig:
        accessLogFile: /dev/stdout
        enableTracing: true
        accessLogFormat:
          '{"start_time":"%START_TIME%","remote_address":"%DOWNSTREAM_DIRECT_REMOTE_ADDRESS%","user_agent":"%REQ(USER-AGENT)%","host":"%REQ(:AUTHORITY)%","request":"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%","request_time":"%DURATION%","status":"%RESPONSE_CODE%","status_details":"%RESPONSE_CODE_DETAILS%","bytes_received":"%BYTES_RECEIVED%","bytes_sent":"%BYTES_SENT%","upstream_address":"%UPSTREAM_HOST%","upstream_response_flags":"%RESPONSE_FLAGS%","upstream_response_time":"%RESPONSE_DURATION%","upstream_service_time":"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%","upstream_cluster":"%UPSTREAM_CLUSTER%","x_forwarded_for":"%REQ(X-FORWARDED-FOR)%","request_method":"%REQ(:METHOD)%","request_path":"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%","request_protocol":"%PROTOCOL%","tls_protocol":"%DOWNSTREAM_TLS_VERSION%","request_id":"%REQ(X-REQUEST-ID)%","sni_host":"%REQUESTED_SERVER_NAME%","apigee_dynamic_data":"%DYNAMIC_METADATA(envoy.lua)%"}'
      components:
      - enabled: true
        name: istio-ingressgateway
        k8s:
          service:
            type: LoadBalancer
            ports:
            - name: status-port
              port: 15021
              targetPort: 15021
            - name: http2
              port: 80
              targetPort: 8080
            - name: https
              port: 443
              targetPort: 8443
    
  2. 使用 asm-multicloud 設定檔,透過 istioctl 安裝 Anthos 服務網格:
    istioctl install \
        --set profile=asm-multicloud \
        --set revision="" \
        --filename overlayfile.yaml

    輸出內容應如下所示:

    kubectl get pods -n istio-system
    NAME                                   READY   STATUS    RESTARTS   AGE
    istio-ingressgateway-88b6fd976-flgp2   1/1     Running   0          3m13s
    istio-ingressgateway-88b6fd976-p5dl9   1/1     Running   0          2m57s
    istiod--798ffb964-2ls88       1/1     Running   0          3m21s
    istiod--798ffb964-fnj8c       1/1     Running   1          3m21s

    --set revision 引數會將以 istio.io/rev=1.6.11-asm.1 格式編寫的修訂版本標籤新增至 istiod。自動附加元件注入器 webhook 會使用修訂版本標籤,將注入的附加元件與特定 istiod 修訂版本建立關聯。如要為命名空間啟用自動補充插入功能,您必須使用與 istiod 上的標籤相符的修訂版本標記命名空間。

  3. 確認安裝作業已完成:
    kubectl get svc -n istio-system

    輸出內容應如下所示:

    NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                                                                      AGE
    istio-ingressgateway   LoadBalancer   172.200.48.52    34.74.177.168   15021:30479/TCP,80:30030/TCP,443:32200/TCP,15012:32297/TCP,15443:30244/TCP   3m35s
    istiod                 ClusterIP      172.200.18.133   <none>          15010/TCP,15012/TCP,443/TCP,15014/TCP                                        4m46s
    istiod-       ClusterIP      172.200.63.220   <none>          15010/TCP,15012/TCP,443/TCP,15014/TCP                                        3m43s

復原升級

如要還原先前的升級,請按照下列步驟操作:

  1. 清理混合式執行階段命名空間的已完成工作,其中 NAMESPACE 是覆寫檔案中指定的命名空間 (如果您已指定命名空間)。如未指定,預設命名空間為 apigee
    kubectl delete job -n NAMESPACE \
      $(kubectl get job -n NAMESPACE \
      -o=jsonpath='{.items[?(@.status.succeeded==1)].metadata.name}')
  2. 清理 apigee-system 命名空間的已完成工作:
    kubectl delete job -n apigee-system \
      $(kubectl get job -n apigee-system \
      -o=jsonpath='{.items[?(@.status.succeeded==1)].metadata.name}')
  3. 變更 APIGEECTL_HOME 變數,讓其指向包含舊版 apigeectl 的目錄。例如:
    export APIGEECTL_HOME=PATH_TO_PREVIOUS_APIGEECTL_DIRECTORY
  4. 在要回溯至的安裝根目錄中,執行 ${APIGEECTL_HOME}/apigeectl apply,檢查 Pod 狀態,然後執行 ${APIGEECTL_HOME}/apigeectl init。請務必使用原始覆寫檔案,以便還原至所需版本:
    1. hybrid-files 目錄中執行 ${APIGEECTL_HOME}/apigeectl apply
      ${APIGEECTL_HOME}/apigeectl apply -f ./overrides/ORIGINAL_OVERRIDES.yaml
    2. 請檢查這些 pod 的狀態:
      kubectl -n NAMESPACE get pods

      其中 NAMESPACE 是 Apigee 混合式命名空間。

    3. 檢查 apigeeds 的狀態:
      kubectl describe apigeeds -n apigee

      輸出內容應如下所示:

      Status:
        Cassandra Data Replication:
        Cassandra Pod Ips:
          10.8.2.204
        Cassandra Ready Replicas:  1
        Components:
          Cassandra:
            Last Successfully Released Version:
              Revision:  v1-f8aa9a82b9f69613
              Version:   v1
            Replicas:
              Available:  1
              Ready:      1
              Total:      1
              Updated:    1
            State:        running
        Scaling:
          In Progress:         false
          Operation:
          Requested Replicas:  0
        State:                 running

      只有在 apigeeds ßpod 執行時,才能繼續執行下一個步驟。

    4. 執行 apigeectl init
      ${APIGEECTL_HOME}/apigeectl init -f ./overrides/ORIGINAL_OVERRIDES.yaml