Google cloud platform 将GCP服务帐户密钥传递给GKE pods

Google cloud platform 将GCP服务帐户密钥传递给GKE pods,google-cloud-platform,google-kubernetes-engine,google-iam,Google Cloud Platform,Google Kubernetes Engine,Google Iam,我在TF(0.11.14)中创建了一个GCP角色,将其附加到服务帐户,并为后者创建了一个密钥,如下所示: resource "google_service_account_key" "my_service_account_key" { service_account_id = "${google_service_account.my_service_account.id}" } 然后,我以以下方式将私钥作为输出: output &

我在TF(
0.11.14
)中创建了一个GCP角色,将其附加到服务帐户,并为后者创建了一个密钥,如下所示:

resource "google_service_account_key" "my_service_account_key" {
  service_account_id = "${google_service_account.my_service_account.id}"
}
然后,我以以下方式将
私钥
作为输出:

output "my_service_account_private_key" {
  value       = "${google_service_account_key.my_service_account_key.private_key}"
  sensitive   = true
}
它给我印了一条很长的线

ewogICJK49fo34KFo4 .... 49k92kljg==
假设该角色具有对GCS存储桶进行读/写操作的权限,我如何将上述凭证/私钥传递给(GKE)pod/部署,以便pod被授予特定的服务帐户(从而能够执行相应权限允许的操作,例如对存储桶进行读/写操作)?

您的主要步骤是

  • 创建一个服务帐户
  • 为您的服务帐户提供必要的角色以使用GCS bucket
  • 将帐户密钥另存为Kubernetes机密
  • 使用服务帐户配置和部署应用程序

  • 我相信你已经完成了第一步和第二步。我研究了两个示例(,),它们可能对剩下的步骤有所帮助。

    我的建议:忘记服务帐户密钥文件并使用