解除安裝 Knative serving GKE 外掛程式

從叢集中解除安裝 Knative 服務「GKE 外掛程式」,包括相關資源和標籤。

在這項工作中,您將使用遷移指令碼,從叢集中移除「GKE 外掛程式」,現有的所有 Knative 服務資源都會保留在叢集中,並繼續提供流量。

事前準備

總覽

解除安裝 GKE 外掛程式包括:

  1. 確認節點集區符合升級需求。
  2. 套用遷移標籤並建立准入 Webhook ValidatingWebhookConfiguration,防止 Knative 服務資源在下列命名空間中遭到刪除:
    • knative-serving
    • cloud-run-system
    • gke-system
  3. 解除安裝「GKE 外掛程式」,包括從 Knative 服務資源中移除相關管理員標籤。

    請注意,這項程序可能需要超過 10 分鐘才能完成。

  4. 新增 appdevexperience-operator 註解。

  5. 移除未與車隊搭配使用的過時 cloudrun.operator.run.cloud.google.com 資源。

解除安裝 Knative serving GKE 外掛程式

在本節中,您會使用遷移指令碼解除安裝「GKE 外掛程式」。

  1. 執行下列指令來啟動遷移指令碼:

    ./migration-addon.sh --command uninstall-cloudrun-addon
    
  2. 在終端機中,遷移指令碼會提示您確認是否要執行各項動作。輸入 y 開始程序,並在每個提示中繼續操作。

    解除安裝「GKE 外掛程式」時,系統會顯示類似下方的提示:

    In this process, the script performs the following:
    1. Validating the node pool to make sure it meets the requirements for
       upgrading. Confirming node pool requirements for
       my-gcp-project/us-central1-c/my-gke-cluster...
    2. Applying the required migration labels
       namespace/knative-serving labeled
    3. Create a ValidatingWebhookConfiguration admission webhook to prevent
       the deletion of resources under the following namespaces:
       knative-serving, cloud-run-system, and gke-system
    Continue? [Y/n] y
    
    validatingwebhookconfiguration.admissionregistration.k8s.io/prevent-deletion-cloud-run-resources created
    ValidatingWebhookConfiguration prevent-deletion-cloud-run-resources for preventing deleting Knative serving resources is effective.
    
    4. Uninstall the Knative serving GKE add-on? Your
    Knative serving resources remain in your cluster.
    Continue? [Y/n] y
    
    Updating my-gke-cluster...
    
    5. Removing the add-on manager labels and adding the Operator related
      annotations. This step will take about 10 minutes.
    
    customresourcedefinition.apiextensions.k8s.io/certificates.networking.internal.knative.dev annotated
    
    6. Clean up unused stale Knative serving operator.
    
    cloudrun.operator.run.cloud.google.com "cloud-run" deleted
    No resources found
    
    Knative serving GKE add-on is successfully uninstalled.
    
  3. 執行下列指令,確認「GKE 外掛程式」已disabled

    gcloud container clusters describe ${CLUSTER_NAME} --region ${CLUSTER_LOCATION} --project ${PROJECT_ID} --format='get(addonsConfig.cloudRunConfig.disabled)'
    

    如果「GKE 外掛程式」已從叢集中移除,系統會傳回 True

後續步驟

遷移至 Cloud Service Mesh

復原

如要還原透過上述步驟所做的變更,可以使用遷移指令碼執行下列操作:

  • 重新啟用 Knative serving「GKE 外掛程式」。
  • 移除 ValidatingWebhookConfiguration 准入 Webhook。

如要開始回溯程序,請按照下列步驟操作:

  1. 執行下列指令來啟動遷移指令碼:

    ./migration-addon.sh --command rollback-uninstall-cloudrun-addon
    
  2. 在終端機中,遷移指令碼會提示您確認是否要執行各項動作。在每個提示中輸入 y,然後繼續操作。

    重新啟用「GKE 外掛程式」時,系統會顯示類似下列的提示:

    In this step, the script performs the following:
      1. Enable Knative serving GKE add-on
      2. Remove the ValidatingWebhookConfiguration added for uninstalling addon
    Continue? [Y/n] Y
    
    1. Enable Knative serving GKE add-on?
    Continue? [Y/n] Y
    
    Updating my-gke-cluster...done.
    Knative serving GKE add-on is enabled
    
    2. Remove the ValidatingWebhookConfiguration added for uninstalling addon?
    Continue? [Y/n] Y
    
    Removing the ValidatingWebhookConfiguration used to prevent deletion
    
  3. 確認 Knative serving「GKE 外掛程式」已重新啟用:

    gcloud container clusters describe ${CLUSTER_NAME} --region ${CLUSTER_LOCATION} --project ${PROJECT_ID} --format='get(addonsConfig.cloudRunConfig)'
    

    如果外掛程式在叢集中執行,系統會傳回外掛程式的設定詳細資料。範例:

    loadBalancerType=LOAD_BALANCER_TYPE_EXTERNAL