【问题标题】:Unable to pull docker image into Kubernetes Pod from Google Container Registry无法从 Google Container Registry 将 docker 映像拉入 Kubernetes Pod
【发布时间】:2023-03-07 20:27:01
【问题描述】:

我已阅读此question 和此one,并使用具有项目的服务帐户 JSON 密钥为 Google Container Registry 创建了我的 Kubernetes 密钥:所有者和查看者权限。我还通过控制台验证了该图像确实存在于 Google Container Registry 中。

我也读过这个document

当我跑步时:

minikube dashboard

然后在用户界面中,单击“+”sybmol,指定我的图像的 URL,如下所示:

project-123456/bot-image

然后点击“高级选项”并指定导入的 Secret。

几秒钟后我看到了这个错误:

Error: Status 403 trying to pull repository project-123456/bot-image: "Unable to access the repository: project-123456/bot-image; please verify that it exists and you have permission to access it (no valid credential was supplied)."

如果我查看 Secret 文件 (.dockerconfigjson) 中的内容,就会发现: {"https://us.gcr.io": {"email": "admin@domain.com", "auth": "longtexthere"}}

可能是什么问题?

【问题讨论】:

    标签: google-cloud-platform google-container-registry


    【解决方案1】:

    json 需要有一个顶级的"{auths": json 密钥来自:

    Creating image pull secret for google container registry that doesn't expire?

    所以 json 的结构应该是这样的:

    {"auths":{"https://us.gcr.io": {"email": "admin@domain.com", "auth": "longtexthere"}}}

    如果您仍然遇到问题,您也可以下载最新版本的 minikube (0.17.1) 并运行 minikube addons configure registry-creds 按照那里的提示设置信用 然后运行minikube addons enable registry-creds

    现在您应该可以使用如下结构的 yaml 从 GCR 中拉下 pod:

    apiVersion: v1
    kind: Pod
    metadata:
      name: foo
      namespace: default
    spec:
      containers:
        - image: gcr.io/example-vm/helloworld:latest
          name: foo
    

    编辑:2018 年 6 月 13 日更新命令以反映 @Rambatino 的评论

    【讨论】:

    • 感谢亚伦。我下载了 .17.1,使用 GCR 启用了注册表凭据并导入了 JSON 密钥。它报告“registry-creds 已成功启用”,但是当我尝试使用 GCR 映像创建部署时,它仍然失败,并且没有填充任何新的 Secret。
    • 确保您没有收到错误消息:Could not read file for application_default_credentials.json 您还可以验证 ImagePullSecret 是使用以下内容创建的:kubectl describe serviceaccount 您是否还在图像中添加了 gcr 前缀?我添加了一个示例 pod 规范,该规范适用于我的原始答案。
    • 您最终解决了这个问题吗?如果更简单,你也可以在 github 上发布问题:github.com/kubernetes/minikube
    • 启用注册表凭据已拆分为两个命令:minikube addons configure registry-creds && minikube addons enable registry-creds (github.com/kubernetes/minikube/issues/1391)
    猜你喜欢
    • 1970-01-01
    • 2022-01-22
    • 2017-07-02
    • 2020-10-03
    • 2021-03-13
    • 2019-09-25
    • 2018-10-31
    • 2018-04-22
    • 1970-01-01
    相关资源
    最近更新 更多