為管理員叢集設定準備好的憑證

預先準備的憑證可讓您將 Google Distributed Cloud 軟體 only for VMware 管理員叢集的憑證,儲存在管理員叢集本身的 Secret 中,因此您不必在管理員工作站中保留密碼和服務帳戶金鑰。

程序總覽

  1. 填寫 Secret 設定檔。

  2. 在管理員叢集設定檔中,將 preparedSecrets.enabled 設為 true。

  3. 執行 gkectl prepare。

  4. 建立管理員叢集。

填寫 Secret 設定檔

產生 Secrets 設定檔的範本:

gkectl create-config secrets

上述指令會產生名為 secrets.yaml 的檔案。您可以視需要變更這個檔案的名稱和位置。

請參閱密鑰設定檔文件,熟悉設定檔。建議您在另一個分頁或視窗中開啟這份文件。

以下是 Secrets 設定檔範例。一個 Secret 群組包含 vCenter 憑證和四個服務帳戶金鑰的值:

apiVersion: v1
kind: ClusterSecrets
secretGroups:
- secrets:
    vCenter:
      username: "my-vcenter-account"
      password: "U$icUKEW#INE"
    componentAccessServiceAccount:
      serviceAccountKeyPath: "my-key-folder/component-access-key.json"
    registerServiceAccount:
      serviceAccountKeyPath: "my-key-folder/connect-register-key.json"
    stackdriverServiceAccount:
      serviceAccountKeyPath: "my-key-folder/log-mon-key.json"
    cloudAuditLoggingServiceAccount:
      serviceAccountKeyPath: "my-key-folder/audit-log-key.json"

管理員叢集設定檔

按照「建立管理員叢集」一文所述,建立管理員叢集設定檔。

在管理員叢集設定檔中,將 preparedSecrets.enabled 設為 true:

preparedSecrets:
  enabled: true

在管理員叢集設定檔中,請勿指定下列欄位的值。這些欄位並非必要,因為 Google Distributed Cloud 軟體 (僅限 VMware) 會從您準備的 Secret 取得憑證和金鑰。

  • vCenter.credentials.fileRef.path
  • componentAccessServiceAccountKeyPath
  • loadBalancer.f5BigIP.credentials.fileRef.path
  • gkeConnect.registerServiceAccountKeyPath
  • stackdriver.serviceAccountKeyPath
  • cloudAuditLogging.serviceAccountKeyPath
  • privateRegistry.credentials.fileRef.path

初始化環境

將 OS 映像檔匯入 vSphere,並將容器映像檔推送至私人登錄檔 (如有指定):

gkectl prepare --config ADMIN_CLUSTER_CONFIG --secret-config SECRETS_CONFIG

更改下列內容:

  • ADMIN_CLUSTER_CONFIG:管理員叢集設定檔的路徑

  • SECRETS_CONFIG:Secret 設定檔的路徑

建立管理員叢集

建立管理員叢集:

gkectl create admin --config ADMIN_CLUSTER_CONFIG --secret-config SECRETS_CONFIG

更改下列內容:

  • ADMIN_CLUSTER_CONFIG:管理員叢集設定檔的路徑

  • SECRETS_CONFIG:Secret 設定檔的路徑

輪替憑證

如要輪替憑證,您需要 Secret 設定檔。您可以採取兩種做法:

  • 執行 gkectl create-config secrets 即可產生新的 Secrets 設定檔。在檔案中填入新的服務帳戶金鑰。

  • 從管理員叢集產生 Secret 設定檔。然後將選取的服務帳戶金鑰更換為新金鑰。

    如要從管理員叢集產生 Secrets 設定檔,請按照下列步驟操作:

    gkectl get-config admin --export-secrets-config \
      --bundle-path BUNDLE \
      --kubeconfig ADMIN_CLUSTER_KUBECONFIG
    

    更改下列內容:

    • BUNDLE:Google Distributed Cloud 軟體 (僅限 VMware) 軟體包檔案的路徑

    • ADMIN_CLUSTER_KUBECONFIG:管理員叢集 kubeconfig 檔案的路徑

輪替憑證:

gkectl update credentials CREDENTIAL_TYPE \
    --config ADMIN_CLUSTER_CONFIG \
    --kubeconfig ADMIN_CLUSTER_KUBECONFIG \
    --secret-config SECRETS_CONFIG \
    --admin-cluster

更改下列內容:

  • CREDENTIAL_TYPE:下列其中一項:vsphere、f5bigip、privateregistry、componentaccess、register、stackdriver、cloudauditlogging。

  • ADMIN_CLUSTER_CONFIG:管理員叢集設定檔的路徑

  • ADMIN_CLUSTER_KUBECONFIG:管理員叢集 kubeconfig 檔案的路徑

  • SECRETS_CONFIG:Secret 設定檔的路徑

更新

如要更新使用預先準備憑證的管理員叢集,在多數情況下,您可以按照「更新叢集」中的指示操作。

不過,如果您想在更新過程中啟用 Cloud Logging 和 Cloud Monitoring 或 Cloud 稽核記錄,請按照下列步驟操作:

  1. 產生密鑰設定檔。

  2. 在 Secrets 設定檔中,提供 stackdriverServiceAccount.serviceAccountKeyPath 或 cloudAuditLoggingServiceAccount.serviceAccountKeyPath 的值,或兩者皆提供。

  3. 更新叢集:

    gkectl update admin --kubeconfig ADMIN_CLUSTER_KUBECONFIG \
       --config ADMIN_CLUSTER_CONFIG \
       --secret-config SECRETS_CONFIG