服務帳戶驗證

Apigee Hybrid 會進行驗證,確保服務帳戶金鑰位置正確,且帳戶在 GCP 專案中具備適當權限。這項驗證功能預設為啟用。

本節說明如何啟用或停用服務帳戶驗證。此外,這個步驟可確保您已為 GCP 專案啟用適當的 API,以便進行驗證。

啟用服務帳戶權限驗證

如何啟用權限驗證:

  1. 請確認您的 GCP 專案已啟用 Cloud Resource Manager API
    1. 開啟 Google Cloud 控制台,並使用您在步驟 1:建立 Google Cloud 帳戶中建立的帳戶登入。
    2. 選取您在「步驟 2:建立 Google Cloud 專案」中建立的專案。
    3. 依序選取「API 和服務」>「程式庫」
    4. 搜尋「Cloud Resource Manager」。
    5. 找到「Cloud Resource Manager API」服務並點選。
    6. 如果尚未啟用,請點選「啟用」

    您也可以使用 gcloud 啟用 API:

    gcloud services enable cloudresourcemanager.googleapis.com --project GCP_project_ID
  2. 在覆寫檔案中,新增 validateServiceAccounts 屬性並設為 true。例如:
    ...
    # Enables strict validation of service account permissions.
    validateServiceAccounts: true
    ...

啟用驗證後,每當 apigeectl 將 Apigee Hybrid 執行階段元件套用至叢集時,都會驗證覆寫檔案中包含的服務帳戶金鑰。

排解驗證錯誤

如果驗證失敗,執行階段部署作業會停止,且 apigeectl 會結束。 如要排解服務帳戶失敗問題,請瞭解驗證檢查權限的順序:

  1. 專案 ID 的權限。
  2. (僅適用於 UDCA 和 Synchronizer) 如果專案的權限檢查失敗,驗證程序會繼續檢查 Apigee 環境的 IAM 政策權限。這些 SA 的範圍是環境,且環境支援更精細的權限。

    如要更新特定環境的 IAM 政策,請前往混合式使用者介面。依序前往「管理」>「環境」>「存取權」

舉例來說,以下是權限檢查失敗的錯誤訊息:

Invalid Metrics Service Account. Service Account
"apigee-metrics@hybrid-project.iam.gserviceaccount.com" is missing 1 or more required
permissions [monitoring.metricDescriptors.create monitoring.metricDescriptors.get monitoring.metricDescriptors.list
monitoring.monitoredResourceDescriptors.get monitoring.monitoredResourceDescriptors.list monitoring.timeSeries.create].
Visit Service accounts and roles used by
hybrid components for more details on setting up Apigee hybrid service account permissions.

如要修正這項錯誤,請將必要角色新增至服務帳戶。如要瞭解如何建立及修改服務帳戶,請參閱「 建立服務帳戶」。如要查看各 Apigee Hybrid 元件的必要權限,請參閱混合式元件使用的服務帳戶和角色

停用權限驗證

如要停用服務帳戶權限驗證,請在覆寫檔案中將 validationServiceAccounts 屬性設為 false,如下列範例所示:

...
# Enables strict validation of service account permissions.
validateServiceAccounts: false
...