自動管理負載平衡器的憑證生命週期
瞭解如何使用 Certificate Manager (第 2 代),自動管理全球應用程式負載平衡器的 Google 代管憑證生命週期。
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Compute Engine, Certificate Manager, Certificate Authority Service APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Compute Engine, Certificate Manager, Certificate Authority Service APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.- 您需要現有的應用程式負載平衡器,且至少有一個目標 HTTPS Proxy。詳情請參閱選擇負載平衡器。
必要的角色
如要取得設定生命週期管理所需的權限,請要求管理員授予您專案的下列 IAM 角色:
- Certificate Manager 編輯者 (
roles/certificatemanager.editor) - 負載平衡器管理員 (
roles/compute.loadBalancerAdmin)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
這些預先定義的角色具備設定生命週期管理所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:
所需權限
如要設定生命週期管理,必須具備下列權限:
-
compute.targetHttpsProxies.update -
compute.targetSslProxies.update -
compute.targetHttpsProxies.setCertificateMap -
compute.targetSslProxies.setCertificateMap -
compute.sslCertificates.*
設定憑證生命週期管理
如要設定負載平衡器憑證的生命週期管理:
前往 Google Cloud 控制台的「Certificate Manager (第 2 代)」。
在導覽選單中,按一下「管理生命週期」。
按一下「負載平衡」分頁標籤。系統會顯示負載平衡器清單。
展開負載平衡器資料列,即可查看附加的憑證。
按一下目標 Proxy 的名稱。
按一下「設定生命週期管理」。該頁面會顯示相關聯的憑證清單,您可以新增及移除憑證。
按一下「憑證」,然後按一下「新增憑證」。
選取現有憑證或建立新憑證。
輸入新憑證的下列詳細資料:
- 名稱:輸入不重複的名稱 (例如
my-lb-cert)。 - 範圍:選取適當的金鑰發布範圍 (例如
Default)。 - 憑證類型:選取「自行管理的憑證」或「Google 代管的憑證」。詳情請參閱「憑證類型」。
- 網域名稱:輸入這個憑證涵蓋的網域名稱 (例如
app.example.com)。這個網域必須由您控管。 - 核發設定:從清單中選取現有的核發設定。這項設定會決定憑證授權單位、效期和金鑰類型。
- 名稱:輸入不重複的名稱 (例如
點按「Create」(建立)。控制台會將新憑證新增至目標 Proxy 的清單。
查看憑證清單,然後按一下「更新」,將變更套用至目標 Proxy。
驗證設定
如要驗證憑證設定,請按照下列步驟操作:
檢查憑證狀態。核發和佈建作業可能需要幾分鐘到幾小時的時間。憑證的起始狀態為「待處理」。
在 Certificate Manager (第 2 代) 的「憑證」分頁中,監控憑證狀態。狀態為「有效」時,憑證即可使用。
確認網域的 DNS 記錄指向負載平衡器 IP 位址。
使用 HTTPS 存取服務 (例如
https://app.example.com),測試設定是否正常運作。
清除所用資源
為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。
從目標 Proxy 移除憑證:
- 前往目標 Proxy 的「管理生命週期」>「負載平衡」分頁。
- 找出您建立的憑證 (
my-lb-cert)。 - 從清單中移除憑證。
- 按一下「Update」。
刪除憑證資源:
- 前往 Certificate Manager (第 2 代) 的「憑證」分頁。
- 選取憑證 (
my-lb-cert)。 - 點選「刪除」。
您不需要刪除在本快速入門導覽課程中建立或使用的負載平衡器、目標 Proxy 或憑證核發設定。