Google Cloud Jenkins gcloud 推送访问被拒绝

Google Cloud Jenkins gcloud push access denied

我正在尝试通过 Jenkins 将映像推送到容器存储库。起初它是有效的,但现在,我得到了 "access denied"

docker -- push gcr.io/xxxxxxx-yyyyy-138623/myApp:master.1
The push refers to a repository [gcr.io/xxxxxxx-yyyyy-138623/myApp]
bdc3ba7fdb96: Preparing
5632c278a6dc: Waiting
denied: Access denied.

Jenkinsfile 看起来像:

  sh("gcloud docker --authorize-only")
  sh("docker -- push gcr.io/xxxxxxx-yyyyy-138623/hotelpro4u:master.1")

备注:

我卡住了 12 个小时....我需要帮助

该错误意味着 GKE 节点无权推送到支持您的存储库的 GCS 存储桶。

这可能是因为:

  1. 集群没有正确的范围来向 GCS 进行身份验证。您是否创建了带有 --scopes storage-rw 的集群?
  2. 集群 运行 的服务帐户没有存储桶的权限。检查项目的 IAM & Admin section 以确保服务帐户具有必要的角色。

基于@cj-cullen 的上述回答,您有两个选择:

  1. 销毁节点池,然后从 CLI, 使用缺少的 https://www.googleapis.com/auth/projecthosting,storage-rw 范围重新创建它。从控制台创建节点池时,GKE 控制台无法更改默认范围。

  2. 停止集群中的每个实例。在控制台中,单击实例的编辑按钮。您现在应该能够添加适当的 https://www.googleapis.com/auth/projecthosting,storage-rw 范围。