简体   繁体   English

GKE / Cloud IAM 工作负载身份设置错误 403

[英]GKE / Cloud IAM workload Identity setup error 403

We have setup a CloudSQL proxy as a sidecar container for one of our Java / Tomcat based app.我们已经为我们的一个基于 Java / Tomcat 的应用程序设置了一个 CloudSQL 代理作为 sidecar 容器。

Here's how we setup workload identity to enable our app to connect to CloudSQL through cloudsql proxy:以下是我们如何设置工作负载标识以让我们的应用程序能够通过 cloudsql 代理连接到 CloudSQL:

  1. Created Cloud IAM Service Account and gave it SQL Client permission:创建 Cloud IAM 服务帐户并授予它 SQL 客户端权限:

  2. Setup Policy Binding as follows:设置策略绑定如下:

     gcloud iam service-accounts add-iam-policy-binding \\ --role roles/iam.workloadIdentityUser \\ --member "serviceAccount:[PROJECT_ID].svc.id.goog[default/default]" \\ [GSA_NAME]@[PROJECT_ID].iam.gserviceaccount.com
  3. Added annotation to GKE Service Account:向 GKE 服务帐户添加了注释:

     kubectl annotate serviceaccount \\ --namespace [K8S_NAMESPACE] \\ [KSA_NAME] \\ iam.gke.io/gcp-service-account=[GSA_NAME]@[PROJECT_ID].iam.gserviceaccount.com
  4. But when we test this using:但是当我们使用以下方法测试时:

     kubectl run --rm -it \\ --generator=run-pod/v1 \\ --image google/cloud-sdk:slim \\ --serviceaccount [KSA_NAME] \\ --namespace [K8S_NAMESPACE] \\ workload-identity-test

Despite doing everything correctly as explained on this page still results in:尽管按照此页面上的说明正确执行了所有操作,但仍会导致:

Error 403: The client is not authorized to make this request., notAuthorized

It turns out there is a glitch in Google Cloud IAM which seems to affect service accounts.事实证明,Google Cloud IAM 中存在一个似乎影响服务帐户的故障

  1. Delete the existing Cloud IAM service account created in step 1 and role associated with it.删除在步骤 1 中创建的现有 Cloud IAM 服务帐号以及与其关联的角色。
  2. Recreate the service account again (with exam same permissions)再次重新创建服务帐户(具有相同的考试权限)

which should fix the issue.这应该解决问题。 Of course you'll have to redo step 2 and 3 again to complete the setup but it works.当然,您必须再次重做第 2 步和第 3 步才能完成设置,但它可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用工作负载身份为 GKE 节点池绑定 GCP IAM - GCP IAM Binding for GKE Node Pool using Workload Identity 无法通过具有 Workload Identity 的 GKE 连接到 Cloud SQL 代理 - Cannot connect to Cloud SQL Proxy through GKE with Workload Identity 如何在启用了工作负载身份的 GKE 上将 Cloud Trace 与 Nodejs 结合使用? - How to use Cloud Trace with Nodejs on GKE with workload identity enabled? 无法在 GKE 上启用工作负载身份 - Fail to enable Workload identity on GKE 所有命名空间的 GKE Workload Identity 服务帐号 - GKE Workload Identity service account for all namespaces 谷歌云 IAM 工作负载身份联合与 azure 广告“应用注册”/“企业应用程序” - google cloud IAM workload identity federation with azure ad 'app registration'/'enterprise applications' GKE 工作负载身份池 VS 来自工作负载身份联合的工作负载身份池 - GKE workload identity pool VS workload identity pools from workload identity federation 使用 GKE 中的工作负载身份访问服务帐户密钥 json - Access Service Account key json using workload identity in GKE 使用工作负载身份从 GKE cronjob 运行 kubectl 命令 - Run kubectl command from GKE cronjob using workload identity 是否可以在 GKE 中创建多个工作负载身份 - Is it possible to create more than one workload identity in GKE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM