gcloud - 设置gcloud缓存use_kaniko后权限无效?
问题描述
我在云端构建 Docker 镜像时遇到了一个奇怪的权限错误。我切换到另一台机器,安装了 Gcloud,做了 gcloud init,一切都恢复了。
但是,我注意到在构建图像时,它花费了更长的时间,因为我没有启用 kaniko 缓存(我从这篇文章中了解到:gcloud rebuilds complete container but Dockerfile is the same, only the script has changed)
启用此功能后,我尝试重建我的最后一个图像和 bam,同样的错误消息:
Status: Downloaded newer image for gcr.io/kaniko-project/executor:latest
gcr.io/kaniko-project/executor:latest
error checking push permissions --
make sure you entered the correct tag name, and that you are authenticated correctly, and try again:
checking push permission for "eu.gcr.io/pipeline/tree-par": creating push check transport for eu.gcr.io failed:
GET https://eu.gcr.io/v2/token?scope=repository%3pipeline%2Ftree-par%3Apush%2Cpull&service=eu.gcr.io:
UNAUTHORIZED: You don't have the needed permissions to perform this operation, and you may have invalid credentials.
To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
ERROR
ERROR: build step 0 "gcr.io/kaniko-project/executor:latest" failed: step exited with non-zero status: 1
-------------------------------------------------------------------------------------------------------------------------------
ERROR: (gcloud.builds.submit) build bad4a9a4-054d-4ad7-991d-e5aeae039b7c completed with status "FAILURE"
任何人都知道为什么在启用 Kaniko 缓存时会失败?我讨厌不使用它,因为当它仍然有效时,它确实减少了创建 docker 映像所需的时间。
解决方案
看来问题出在 Kaniko 的头上。
三天前,在v0.21.0版本上,他们添加了这个修复:
修复:GCR 凭证助手检查不尊重 DOCKER_CONFIG 环境变量
即使在此版本发布后 1 天后,也报告了此问题,用户看到了非常相似的错误消息:
“[...] 您没有执行此操作所需的权限,并且您的凭据可能无效[...]”
昨天发布的v0.22.0版本已经解决了这个问题。建议的解决方法是执行以下命令:
gcr.io/kaniko-project/executor:v0.22.0
我建议使用该命令而不是executor:latest
“强制”使用 v0.22.0 版本。
我希望这是有帮助的!:)
推荐阅读
- python - 从 Python 中的二维数组获取非零数据和位置
- html - 为什么 Font Awesome SVG 图标的这种简单颜色变化不起作用?
- python - firebase 无法保存我尝试导入的所有数据
- if-statement - 如果不使用语句
- c# - 如何更有效地传递大小 jsonPayload?
- javascript - 在 React 中实现事件处理程序
- python - 当使用 csv.writer 将特定列写入新文件时,循环会遍历每个字符
- google-bigquery - BigQuery - 混合架构:无法将 STRING 类型的字段读取为 DATETIME
- python - Python configparser 从 S3 读取配置而不下载
- go - 如果一个切片改变,两个切片都会改变