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

本文說明如何在 Google Distributed Cloud 中,為管理員叢集設定準備好的憑證。

準備好憑證後,您就可以將管理員叢集的憑證儲存在管理員叢集的 Secret 中。這項做法可提供安全保障,因為您不必在管理工作站保留密碼和服務帳戶金鑰。

請注意,進階叢集有下列限制:

  • 1.31 版:進階叢集不支援準備好的憑證。
  • 1.32 以上版本:進階叢集支援準備好的憑證。

程序總覽

  1. 填入 Secrets 設定檔。

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

  3. 執行 gkectl prepare

  4. 建立管理員叢集。

填寫密鑰設定檔

產生 Secrets 設定檔的範本:

gkectl create-config secrets

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

請先閱讀「Secrets 設定檔」文件,熟悉設定檔。建議您在另一個分頁或視窗中開啟這份文件。

以下是 Secrets 設定檔的範例。其中一個密鑰群組包含 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 會從您準備的 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:Secrets 設定檔的路徑

建立管理員叢集

建立管理員叢集:

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

更改下列內容:

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

  • SECRETS_CONFIG:Secrets 設定檔的路徑

輪替憑證

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

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

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

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

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

    更改下列內容:

    • BUNDLE:Google Distributed Cloud 套件檔案的路徑

    • 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:密鑰設定檔的路徑

更新

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

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

  1. 產生 Secrets 設定檔

  2. 在 Secrets 設定檔中,提供 stackdriverServiceAccount.serviceAccountKeyPathcloudAuditLoggingServiceAccount.serviceAccountKeyPath 的值,或同時提供兩者的值。

  3. 更新叢集:

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