Cloud 淘汰和破壞性變更一般建議工具
Cloud 淘汰和破壞性變更一般建議工具會提供 Cloud 淘汰和破壞性變更的建議。這項服務會找出即將淘汰和破壞性變更影響的 Cloud 資源,並提供管理指南。您可以透過 Google Cloud CLI、API 和 BigQuery Export 查看建議。
事前準備
- 登入 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 Recommender API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
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 Recommender API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.
- 請確認您具備下列角色:
| 說明 | 角色 |
|---|---|
| 查看建議 |
recommender.cloudDeprecationRecommendationViewer
|
| 查看及更新建議 |
recommender.cloudDeprecationRecommendationAdmin
|
必要的角色
本節說明使用 Cloud 淘汰和破壞性變更一般建議工具的角色和必要權限。
| 角色 | 包含的權限 |
|---|---|
| roles/recommender.cloudDeprecationRecommendationViewer |
|
| roles/recommender.cloudDeprecationRecommendationAdmin |
|
如要進一步瞭解角色和授予存取權,請參閱下列文章:
定價
Cloud 淘汰和破壞性變更一般建議工具不收費。如要瞭解其他定價級別,請參閱「Recommender 定價」。
查看雲端淘汰建議
您可以透過控制台、Google Cloud CLI、Recommender API 或 BigQuery Export 功能列出建議。
控制台
前往「Active Assist」。
將「篩選器欄位」設為
Recommender:google.cloud.deprecation.GeneralRecommender。
Google Cloud CLI
這個分頁顯示使用 Google Cloud CLI 列出建議和洞察的指令。
列出建議
gcloud recommender recommendations list \ --billing-project=BILLING_PROJECT_ID \ --project=PROJECT_ID \ --location=LOCATION \ --recommender=google.cloud.deprecation.GeneralRecommender \ --format=yaml列出洞察資訊
gcloud recommender insights list \ --billing-project=BILLING_PROJECT_ID \ --project=PROJECT_ID \ --location=LOCATION \ --insight-type=google.cloud.deprecation.GeneralInsight \ --format=yaml
更改下列內容:
- BILLING_PROJECT_ID 替換為已啟用 Recommender API 的專案 ID。
- PROJECT_ID: Google Cloud 專案的 ID。
- LOCATION:與建議相關聯的資源所在 Google Cloud 位置 (例如 global 或 us-central1-a)。
API
這個分頁會顯示使用 Recommender API 列出建議和洞察的指令。
可列出建議
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: BILLING_PROJECT_ID" \ "https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloud.deprecation.GeneralRecommender/recommendations"列出洞察資訊
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: BILLING_PROJECT_ID" \ "https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloud.deprecation.GeneralInsight/insights"
更改下列內容:
- BILLING_PROJECT_ID 替換為已啟用 Recommender API 的專案 ID。
- PROJECT_ID: Google Cloud 專案的 ID。
- LOCATION:與建議相關聯的資源所在 Google Cloud 位置 (例如 global 或 us-central1-a)。
BigQuery 匯出內容
這個分頁會顯示使用 BigQuery 匯出功能列出建議的指令。
Cloud 淘汰建議也會包含在 BigQuery Export中。透過 BigQuery Export,您可以查看貴組織的每日建議快照。
按照 BigQuery Export 說明文件,將建議匯出至 BigQuery。
查詢所有淘汰建議:
SELECT * FROM `<project>.<dataset>.recommendations_export` WHERE DATE(_PARTITIONTIME) = "<date>" and recommender = "google.cloud.deprecation.GeneralRecommender"
可用的建議子類型
下表說明可用的建議子類型,以及可揭露的建議子類型。
| 子類型 | 淘汰或破壞性變更? |
|---|---|
| GCE_METADATA_SERVER_HEADER_WHITESPACE | Compute Engine 將在 Compute Engine 中繼資料服務中強制執行 HTTP 要求格式檢查,以符合 RFC 7230 第 3.2 節的規定,因為接受格式不正確的要求可能會導致安全漏洞。 |
請注意,這個表格並未列出所有項目,且可能刻意省略與安全性相關的淘汰項目或破壞性變更。