启用Kaniko缓存后gcloud run deploy触发KeyError:'images'崩溃问题
解决gcloud run deploy时的KeyError: 'images'崩溃问题
镜像构建完成后执行gcloud run deploy命令前,gcloud CLI突然崩溃并报错:
2022-09-19T06:05:37.8347067Z Building Container....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................done 2022-09-19T06:05:37.8351347Z failed 2022-09-19T06:05:37.8352361Z Deployment failed 2022-09-19T06:05:37.8839076Z ERROR: gcloud crashed (KeyError): 'images' 2022-09-19T06:05:37.8839690Z 2022-09-19T06:05:37.8840175Z If you would like to report this issue, please run the following command: 2022-09-19T06:05:37.8840690Z gcloud feedback 2022-09-19T06:05:37.8840875Z 2022-09-19T06:05:37.8841213Z To check gcloud for common problems, please run the following command: 2022-09-19T06:05:37.8847153Z gcloud info --run-diagnostics
问题原因
执行部署脚本的同一用户,在同一构建机的另一个独立构建脚本中启用了Kaniko缓存:
# Enable Kaniko cache to speed up the build gcloud config set builds/use_kaniko True gcloud config set builds/kaniko_cache_ttl 672 # 4 weeks
这是Cloud SDK的已知bug,会导致gcloud run deploy --source与gcloud run deploy --image命令产生冲突,最终触发上述崩溃。
解决方法
启用Kaniko缓存后,同一用户同一机器上的所有gcloud run deploy命令必须使用--image参数。只需将原来的gcloud run deploy --source拆分为两个独立命令:
gcloud builds submit --tag IMAGE_ID(替换IMAGE_ID为你的镜像标识)gcloud run deploy --image IMAGE_ID
内容的提问来源于stack exchange,提问作者Anton Komarov
相关产品推荐
相关产品推荐

