Apigee hybrid 會提供驗證機制,確保服務帳戶的金鑰位置正確,且帳戶在 GCP 專案中具有適當的權限。這項驗證功能預設為啟用。
本節說明如何啟用或停用服務帳戶驗證功能。此外,這個步驟可確保您為 GCP 專案啟用適當的 API,讓驗證程序正常運作。
啟用服務帳戶權限驗證
如何啟用權限驗證:
- 請確認 GCP 專案已啟用
Cloud Resource Manager API:
- 開啟 Google Cloud 控制台,然後使用您在步驟 1:建立 Google Cloud 帳戶中建立的帳戶登入。
- 選取您在步驟 2:建立 Google Cloud 專案中建立的專案。
- 依序選取「API 和服務」>「程式庫」。
- 搜尋「Cloud Resource Manager」。
- 找出「Cloud Resource Manager API」服務,然後按一下。
- 如果尚未啟用,請按一下「啟用」。
您也可以使用 gcloud 啟用 API:
gcloud services enable cloudresourcemanager.googleapis.com --project GCP_project_ID
- 在覆寫檔案中新增
validateServiceAccounts
屬性,並將其設為true
。例如:... # Enables strict validation of service account permissions. validateServiceAccounts: true ...
啟用驗證功能後,每當 apigeectl 將 Apigee 混合式執行階段元件套用至叢集時,就會驗證覆寫檔案中包含的服務帳戶金鑰。
排解驗證錯誤
如果驗證失敗,則會停止執行階段部署作業,並讓 apigeectl
退出。如要排解服務帳戶失敗問題,請務必瞭解驗證程序會按照以下順序檢查權限:
- 專案 ID 的權限。
- (僅適用於 UDCA 和 Synchronizer) 如果專案的權限檢查失敗,驗證程序會繼續檢查 Apigee 環境的 IAM 政策權限。這些 SA 屬於環境層級,而環境支援更精細的權限。
如要更新特定環境的身分與存取權管理政策,請前往混合式 UI。依序前往「管理」>「環境」>「存取」
舉例來說,以下是權限檢查失敗的錯誤訊息:
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 混合式元件的必要權限,請參閱「混合式元件使用的服務帳戶和角色」。
停用權限驗證
如要停用服務帳戶權限驗證功能,請將覆寫檔案中的 validationServiceAccounts
屬性設為 false
,如以下範例所示:
... # Enables strict validation of service account permissions. validateServiceAccounts: false ...