設定受管理工作負載的生命週期管理機制

本文說明如何使用 Certificate Manager (第 2 代),為 Compute Engine 和 Google Kubernetes Engine (GKE) 等代管工作負載設定憑證生命週期管理。您可以使用憑證核發設定,將代管 workload identity pool 連結至憑證授權單位服務集區,自動核發及更新憑證。這有助於避免因憑證過期而導致服務中斷。

代管 Workload Identity 的運作方式

代管 Workload Identity會為 Compute Engine 和 GKE 工作負載提供經過驗證的身分,以及憑證和信任錨點,工作負載會使用這些項目,透過相互傳輸層安全標準 (mTLS) 相互驗證。受管理的工作負載身分會分組至 workload identity pool,做為其中身分的信任邊界。

將 workload identity pool 連結至 CA 服務集區後,Google Cloud 會自動為工作負載核發及更新憑證。這項自動化功能可免除手動管理憑證,並防止服務中斷。

事前準備

  1. 登入 Google Cloud 帳戶。如果您未曾使用過 Google Cloud,歡迎 建立帳戶,親自體驗實際使用我們產品的成效。新客戶還能獲得價值 $300 美元的免費抵免額,用於執行、測試及部署工作負載。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Compute Engine, Certificate Manager, Certificate Authority Service APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Compute Engine, Certificate Manager, Certificate Authority Service APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  10. 確認您已有具備代管型 Workload Identity 的 workload identity pool。詳情請參閱「設定 Compute Engine 的代管 Workload Identity 驗證」或「設定 GKE 的代管 Workload Identity 驗證」。
  11. 確認您已有 CA 服務集區,可向工作負載核發憑證。詳情請參閱「建立 CA 集區」。

必要的角色

如要取得設定生命週期管理所需的權限,請要求管理員在專案中授予您下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

設定受管理工作負載的生命週期

設定代管工作負載身分集區,指定相關聯的工作負載如何從現有的 CA 服務集區接收及更新憑證。

  1. 前往 Google Cloud 控制台的「Certificate Manager (2nd gen)」頁面。

    前往「Certificate Manager (2nd gen)」(Certificate Manager (第 2 代))

  2. 在導覽窗格中,按一下「Manage Lifecycle」(管理生命週期)。
  3. 選取「Managed Workload Identity」分頁標籤。
  4. 找出要設定的 workload identity pool,然後按一下「Configure lifecycle management」(設定生命週期管理)。
  5. 選取「區域」和該區域的「CA 集區」。
  6. 在「Certificate lifetime」(憑證效期) 欄位中,指定核發憑證的效期。值必須介於 21 至 30 天之間。
  7. 將「Rotation window」(輪替時間範圍) 設為 50 到 80 之間的值。這是憑證效期達到這個百分比時,就會觸發更新。
  8. 在「Key algorithm」(金鑰演算法) 欄位中,選取要用來產生私密金鑰的加密演算法。
  9. 按一下「Update」。

後續步驟