简体   繁体   English

从K8S集群调用时,Google API的“身份验证范围不足”

[英]“insufficient authentication scopes” from Google API when calling from K8S cluster

I'm trying to report Node.js errors to Google Error Reporting, from one of our kubernetes deployments running on a GCP/GKE cluster with RBAC. 我正在尝试通过在带有RBAC的GCP / GKE集群上运行的我们的kubernetes部署之一将Node.js错误报告给Google Error Reporting。 (ie permissions defined in a service account associated to the cluster) (即,在与群集关联的服务帐户中定义的权限)

const googleCloud = require('@google-cloud/error-reporting');
const googleCloudErrorReporting = new googleCloud.ErrorReporting();
googleCloudErrorReporting.report('[test] dummy error message');

This works only in certain environments: 这仅在某些环境中有效:

  • it works when run on my laptop, using a service account that has the "Errors Writer" role 当使用具有“错误编写者”角色的服务帐户在笔记本电脑上运行时,它可以工作
  • it works when running in my cluster as a K8S job, after having added the "Errors Writer" role to that cluster's service account 在将“错误编写器”角色添加到该群集的服务帐户后,在作为K8S作业在我的群集中运行时,它可以工作
  • it causes the following error when called from my Node.js application running in one of my K8S deployments: 从在我的K8S部署之一中运行的Node.js应用程序调用时,它将导致以下错误:

ERROR:@google-cloud/error-reporting: Encountered an error while attempting to transmit an error to the Stackdriver Error Reporting API. ERROR:@ google-cloud / error-reporting:尝试将错误传输到Stackdriver Error Reporting API时遇到错误。

Error: Request had insufficient authentication scopes. 错误:请求的身份验证范围不足。

It feels like the job did pick up the permission changes of the cluster's service account, whereas my deployment did not. 感觉这项工作确实获得了群集服务帐户的权限更改,而我的部署却没有。

I did try to re-create the deployment to make it refresh its auth token, but the error is still happening... 我确实尝试过重新创建部署以使其刷新其身份验证令牌,但该错误仍在发生...

Any ideas? 有任何想法吗?

UPDATE : I ended up following Jérémie Girault's suggestion : create a service account and bind it to my deployment. 更新 :我最终遵循JérémieGirault的建议 :创建一个服务帐户并将其绑定到我的部署中。 It works! 有用!

The error message has to do with the access scopes set on the cluster when using the default service account. 错误消息与使用默认服务帐户时在群集上设置的访问范围有关。 You must enable access to the appropriate API. 您必须启用对相应API的访问。

As you mentioned, creating a separate service account, providing it the appropriate IAM permissions and linking it to your cluster or workload will bypass this error as well. 如您所述,创建一个单独的服务帐户,为其提供适当的IAM权限并将其链接到您的群集或工作负载,也将绕过此错误。

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

相关问题 无法从 K8s 集群访问节点应用程序 - Unable to access node app from K8s cluster 将容器从Node / Angular UI部署到K8s集群 - Deploy containers from Node/Angular UI to K8s cluster Google 电子表格 api 请求的身份验证范围不足 - Google spreadsheet api Request had insufficient authentication scopes 当多次调用Google表格时,API身份验证无法用于第二次调用:请求的身份验证范围不足 - When making multiple calls to google sheets API authentication doesn't work for second call: Request had insufficient authentication scopes K8S:是否可以通过Google的Kubernetes Engine API获得群集的KUBECONFIG? (不通过gcloud容器群集获取凭据) - K8S: Can I get my cluster's KUBECONFIG via Google's Kubernetes Engine API? (not via gcloud container clusters get-credentials) K8S 集群中的 Google FCM firebase-admin initializeApp() 错误 - Google FCM firebase-admin initializeApp() error in K8S cluster 使用 nodejs 应用程序中的 k8s 密钥 - use k8s secret from nodejs application k8s 从 nodejs 应用程序中读取 secert - k8s read secert from nodejs application Redis如何在K8s集群的NodeJS中连接服务? - How to connect Redis with service in NodeJS in K8s cluster? 在 k8s 集群上使用 proxy_pass 部署 nginx 和节点时出现随机/间歇性 502 网关错误 - Random/Intermittent 502 gateway errors with nginx and node deployments using proxy_pass on a k8s cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM