為地端部署或其他雲端服務供應商設定 ADC

如果您在 Google Cloud以外的位置執行應用程式,則必須提供 Google Cloud 可辨識的憑證,才能使用 Google Cloud 服務。

Workload Identity 聯盟

如要使用外部 IdP 的憑證向 Google Cloud 進行驗證,建議使用工作負載身分聯盟。您需要建立憑證設定檔,並設定 GOOGLE_APPLICATION_CREDENTIALS 環境變數來指向該檔案。相較於建立服務帳戶金鑰,這種做法更安全。

如需設定 ADC 適用的 Workload Identity Federation,請參閱「Workload Identity Federation with other clouds」(與其他雲端服務搭配使用的 Workload Identity Federation)。

服務帳戶金鑰

如果無法設定 Workload Identity Federation,您必須建立服務帳戶、授予應用程式所需的 IAM 角色,並為服務帳戶建立金鑰。

如要建立服務帳戶金鑰並提供給 ADC 使用,請按照下列步驟操作:

  1. 按照「建立服務帳戶金鑰」一文中的說明,建立具有應用程式所需角色的服務帳戶,以及該服務帳戶的金鑰。
  2. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.

後續步驟