【问题标题】:Failed to pull image myapidemodocker.azurecr.io/apidemo:v4.0: rpc error: code = Unknown desc = unknown blob无法拉取映像 myapidemodocker.azurecr.io/apidemo:v4.0:rpc 错误:代码 = 未知 desc = 未知 blob
【发布时间】:2018-06-17 18:28:52
【问题描述】:

知道为什么我总是收到这个烦人且无用的错误代码/描述吗?

Failed to pull image myapidemodocker.azurecr.io/apidemo:v4.0: rpc error: code = Unknown desc = unknown blob

我想到了不正确的秘密,并按照微软的这个文档没有成功! [https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-aks][1].

上下文:

  • 我正在使用 Visual Studio 和 Docker for Windows 来创建 Windows 容器图像。
  • 映像被推送到 Azure 容器注册 (ACR) 并部署为 Azure 容器实例。不幸的是,我不能将 ACI 用作 生产应用程序,因为它没有连接到私有 vNET。 出于安全原因,不能使用公共 IP,但这就是我们所做的 为 poc!
  • 下一步,在 Azure 中创建 Kubernetes 集群并尝试部署 将相同的图像(Windows 容器)放入 Kubernetes POD,但不是 工作。
  • 让我分享一下我的 yml 定义和事件日志

这是我的 yml 定义:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: apidemo
spec:
  template:
    metadata:
      labels:
        app: apidemo
    spec:
      containers:
      - name: apidemo
        image: myapidemodocker.azurecr.io/apidemo:v4.0
      imagePullSecrets:
      - name: myapidemosecret
      nodeSelector:
       beta.kubernetes.io/os: windows


Event logs:
Events:
  Type     Reason                 Age               From                               Message
  ----     ------                 ----              ----                               -------
  Normal   Scheduled              4m                default-scheduler                  Successfully assigned apidemo-57b5fc58fb-zxk86 to aks-agentp
ool-18170390-1
  Normal   SuccessfulMountVolume  4m                kubelet, aks-agentpool-18170390-1  MountVolume.SetUp succeeded for volume "default-token-gsjhl"
  Normal   SandboxChanged         2m                kubelet, aks-agentpool-18170390-1  Pod sandbox changed, it will be killed and re-created.
  Normal   Pulling                2m (x2 over 4m)   kubelet, aks-agentpool-18170390-1  pulling image "apidemodocker.azurecr.io/apidemo:v4.0"
  Warning  Failed                 20s (x2 over 2m)  kubelet, aks-agentpool-18170390-1  Failed to pull image "apidemodocker.azurecr.io/apidemo:v4
.0": [rpc error: code = Unknown desc = unknown blob, rpc error: code = Unknown desc = unknown blob]
  Warning  Failed                 20s (x2 over 2m)  kubelet, aks-agentpool-18170390-1  Error: ErrImagePull
  Normal   BackOff                10s               kubelet, aks-agentpool-18170390-1  Back-off pulling image "apidemodocker.azurecr.io/apidemo:
v4.0"
  Warning  Failed                 10s               kubelet, aks-agentpool-18170390-1  Error: ImagePullBackOff

(5) 我不明白为什么 Kubernetes 仍然使用来自 default-token-gsjhl/var/run/secrets/kubernetes.io/serviceaccount 作为秘密,而我指定了我自己的!

感谢您抽出宝贵时间提供反馈。

【问题讨论】:

    标签: azure kubernetes


    【解决方案1】:

    我能够解决问题。它与错误消息无关!实际问题是,我尝试使用 Windows Container 镜像,而 Azure 中的 Kubernetes 只支持 Linux Container 镜像。

    这是我必须做的事情:

    • 已配置 Ubuntu (Linux Container on Windows 10)
    • 将 Docker 配置为使用 Linux(切换到 Linux 容器)。
    • 使用 Visual Studio 2017 将 ASP.NET MVC 项目转换为 ASP.NET Core。这是支持包括 Linux 在内的多个平台的重大变化。
    • 更新了 dockerfile 和 docker-compose 项目。
    • 创建了新的 docker 镜像(Linux 容器)。
    • 已将映像推送到 Azure 容器注册表。
    • 在 Kubernetes 中使用相同的凭据创建了一个新部署。成功了!
    • 创建了一个新的Service to expose the app in Kubernetes。此步骤创建了客户端可以使用的端点。
    • 我的 Kubernetes 集群已加入 vNET,并且所有 IP 都是私有的。因此,我通过 Azure API 网关公开了 Kubernetes 端点(服务)。只是为了演示,我允许匿名访问 API(API 密钥和 jwt 令牌是生产应用程序必须的)。
    • 这是应用程序流程:客户端应用程序 -> Azure API 网关 -> Kubernetes 端点(私有 IP) -> Kubernetes PODs -> 我的 Linux 容器

    有很多复杂性,技术规范也在迅速变化。所以,我花了很多时间才把它弄好!我相信你能做到。在此处尝试我的 Azure Kubernetes 服务 API-

    以下是一些配置,供您参考-

    Dockerfile:

    
    
    
    FROM microsoft/aspnetcore:2.0
    ARG source
    WORKDIR /app
    ENV ASPNETCORE_URLS=http://+:80
    EXPOSE 80
    COPY ${source:-obj/Docker/publish} .
    ENTRYPOINT ["dotnet", "gdt.api.demo.dotnetcore.dll"]
    

    Docker-compose:

    
    version: '3'
    
    

    services: gdt-api-demo: image: gdt.api.demo.dotnetcore build: context: .\gdt.api.demo.dotnetcore dockerfile: Dockerfile

    Kubernetes 部署定义:

    
    apiVersion: apps/v1beta1
    kind: Deployment
    metadata:
      name: gdtapidemo
    spec:
      template:
        metadata:
          labels:
            app: gdtapidemo
        spec:
          containers:
          - name: gdtapidemo
            image: gdtapidemodocker.azurecr.io/gdtapidemo-ubuntu:v1.0
          imagePullSecrets:
          - name: gdtapidemosecret
    

    Kubernetes 服务定义:

    
    kind: Service
    apiVersion: v1
    metadata:
      name: gdtapidemo-service
    spec:
      selector:
        app: gdtapidemo-app
      ports:
      - protocol: TCP
        port: 80
        targetPort: 9200
    

    Service as Deployed in Kubernetes

    【讨论】:

    • 很好的故障排除!投赞成票,以防其他人遇到这个问题(因为错误不是很具描述性!)
    • 我在blogs.aspnet4you.com/2018/07/04/… 写了一篇关于将微服务部署到 Kubernetes 的帖子,其中特别说明了 AKS 服务主体的安全要求。希望对您有所帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-20
    相关资源
    最近更新 更多