Kubectl无法从私人gcr.io repo中提取docker镜像

问题描述 投票:0回答:3

我面临同样的问题,从私人GCR拉码头图像,它会引发错误

Failed to pull image "gcr.io/{PROJECT_ID}/{IMAGE:TAG}:latest": rpc error: code = Unknown desc = Error response from daemon: repository gcr.io/{PROJECT_ID}/{IMAGE:TAG} not found: does not exist or no pull access

我尝试但仍未解决问题的解决方案:1。删除群集并重新创建2.将编辑器存储管理员提供给用于提取图像的服务帐户。

此外,当我使用服务帐户身份验证尝试docker image pull时,我可以将图像下载到我的本地

docker image pull gcr.io/{PROJECT_ID}/{IMAGE:TAG}

任何建议\帮助我错过了什么

谢谢

docker google-cloud-platform google-kubernetes-engine google-container-registry
3个回答
0
投票

我建议您确保在群集中设置适当的范围,以便服务帐户提取图像。 Here是一篇文章,提供有关如何授予用户从注册表中提取图像的权限的分步说明。


0
投票

您是否从本地计算机上运行kubectl命令? 如果是这样,你应该首先使用,配置kubectl上下文到GKE, gcloud container clusters get-credentials my-cluster --zone=europe-west2-a

在此处阅读更多信息 https://cloud.google.com/sdk/gcloud/reference/container/clusters/get-credentials

您可能必须在执行上述命令之前安装和配置Google Cloud SDK。 https://cloud.google.com/sdk/install https://cloud.google.com/sdk/docs/initializing


0
投票

当我们使用默认服务帐户(没有从GCR中提取图像的权限)创建群集时,这个问题大多提出,因此要解决此问题,我们可以尝试以下方法:

我们需要在创建集群时将范围指定为云平台,以便集群中的节点可以获取从GCR中提取映像的权限

gcloud container clusters create "test-cluster"   --zone "us-central1-a"   --machine-type "n1-standard-1"    --scopes https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/devstorage.read_write  --num-nodes "3"

要么

我们可以在创建具有从Google Container注册表中提取图像权限的群集时分配服务帐户:

*gcloud container clusters create "test-cluster" --zone "us-central1-a" --machine-type "n1-standard-1" --num-nodes "3" --service-account "[email protected]"*

问候

© www.soinside.com 2019 - 2024. All rights reserved.