【问题标题】:Passing GCP service account key to GKE pods将 GCP 服务帐户密钥传递给 GKE pod
【发布时间】:2020-11-07 00:15:35
【问题描述】:

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

resource "google_service_account_key" "my_service_account_key" {
  service_account_id = "${google_service_account.my_service_account.id}"
}

然后我通过以下方式将private_key 作为输出:

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 授予特定的服务帐户(因此是能够执行相应权限允许的操作,例如读取/写入存储桶)?

【问题讨论】:

标签: google-cloud-platform google-kubernetes-engine google-iam


【解决方案1】:

你的主要步骤是

  1. 创建服务帐号。
  2. 为您的服务帐号提供必要的角色以使用 GCS 存储桶。
  3. 将帐户密钥另存为 Kubernetes Secret。
  4. 使用服务帐号配置和部署应用程序。

我相信您已经了解了第 1 步和第 2 步。我研究了两个示例(12),它们可能对其余步骤有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-14
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2020-01-30
    相关资源
    最近更新 更多