重新建立及更新 Google Kubernetes Engine 虛擬叢集

您可以複製現有 Managed Service for Apache Spark on GKE 虛擬叢集的設定、更新複製的設定,然後使用更新設定建立新的 Managed Service for Apache Spark on GKE 叢集。

重新建立及更新 Managed Service for Apache Spark on GKE 叢集

gcloud

  1. 設定環境變數:

    CLUSTER=existing Managed Service for Apache Spark on GKE  cluster name \
      REGION=region
    

  2. 將現有的 Managed Service for Apache Spark on GKE 叢集設定匯出至 YAML 檔案。

    gcloud dataproc clusters export $CLUSTER \
        --region=$REGION > "${CLUSTER}-config.yaml"
    

  3. 更新設定。

    1. 移除 kubernetesNamespace 欄位。建立更新後的叢集時,必須移除這個欄位,以免發生命名空間衝突。

      移除 kubernetesNamespace 欄位的 sed 指令範例:

      sed -E "s/kubernetesNamespace: .+$//g" ${CLUSTER}-config.yaml
      

    2. 進行其他變更,更新 Managed Service for Apache Spark on GKE 虛擬叢集設定,例如變更 Spark componentVersion

  4. 如要建立的叢集與更新叢集同名 (也就是取代原始叢集),請刪除現有的 Managed Service for Apache Spark on GKE 虛擬叢集

  5. 等待先前的刪除作業完成,然後匯入更新後的叢集設定,建立具有更新設定的新 Managed Service for Apache Spark on GKE 虛擬叢集。

    gcloud dataproc clusters import $CLUSTER \
        --region=$REGION \
        --source="${CLUSTER}-config.yaml"

API

  1. 設定環境變數:

    CLUSTER=existing Managed Service for Apache Spark on GKE  cluster name \
      REGION=region
    

  2. 將現有的 Managed Service for Apache Spark on GKE 叢集設定匯出至 YAML 檔案。

    curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)"  "https://dataproc.googleapis.com/v1/projects/${PROJECT}/regions/${REGION}/clusters/${CLUSTER}?alt=json" > "${CLUSTER}-config.json"

  3. 更新設定。

    1. 移除 kubernetesNamespace 欄位。建立更新後的叢集時,必須移除這個欄位,以免發生命名空間衝突。

      移除 kubernetesNamespace 欄位的 jq 指令範例:

      jq 'del(.virtualClusterConfig.kubernetesClusterConfig.kubernetesNamespace)'
      

    2. 進行其他變更,更新 Managed Service for Apache Spark on GKE 虛擬叢集設定,例如變更 Spark componentVersion

  4. 如要建立的叢集與更新叢集同名 (也就是取代原始叢集),請刪除現有的 Managed Service for Apache Spark on GKE 虛擬叢集。

    curl -X DELETE -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://dataproc.googleapis.com/v1/projects/${PROJECT}/regions/${REGION}/clusters/${CLUSTER}"
    

  5. 等待先前的刪除作業完成,然後匯入更新後的叢集設定,建立具有更新設定的新 Managed Service for Apache Spark on GKE 虛擬叢集。

    curl -i -X POST  -H "Authorization: Bearer $(gcloud auth print-access-token)"  -H "Content-Type: application/json; charset=utf-8" -d "@${CLUSTER}-config.json" "https://dataproc.googleapis.com/v1/projects/${PROJECT}/regions/${REGION}/clusters?alt=json"
    

控制台

Google Cloud 控制台不支援匯入現有叢集的設定,藉此重新建立 Managed Service for Apache Spark on GKE 虛擬叢集。