gpt4 book ai didi

azure - 无法拉取镜像 myapidemodocker.azurecr.io/apidemo :v4. 0:rpc 错误:代码 = 未知 desc = 未知 blob

转载 作者:行者123 更新时间:2023-12-02 12:20:40 26 4
gpt4 key购买 nike

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

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

我想到了错误的 secret ,并按照 Microsoft 的文档进行操作,但没有成功! [https://learn.microsoft.com/en-us/azure/container-registry/container-registry-auth-aks][1] .

上下文:

  • 我使用 Visual Studio 和 Docker for Windows 来创建 Windows容器镜像。
  • 镜像被推送到 Azure 容器寄存器 (ACR) 并部署为Azure 容器实例。不幸的是,我不能使用 ACI 作为生产应用程序,因为它未连接到私有(private) vNET。出于安全原因不能使用公共(public) 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 作为 secret 而我指定了我自己的!

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

最佳答案

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

这是我必须执行的操作:

  • 已配置的 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 都是私有(private)的。因此,我通过 Azure API 网关公开了 Kubernetes 端点(服务)。只是为了演示,我允许匿名访问 API(生产应用程序必须使用 API key 和 jwt token )。
  • 以下是应用程序流程:客户端应用程序 -> Azure API 网关 -> Kubernetes 端点(私有(private) IP) -> Kubernetes POD -> 我的 Linux 容器

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

以下是我用于供您引用的一些配置 -

Dockerfile:

<p></p>

<pre><code>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"]
</code></pre>

<p></p>

Docker 组合:


version: '3'<p></p>

<p>services:
gdt-api-demo:
image: gdt.api.demo.dotnetcore
build:
context: .\gdt.api.demo.dotnetcore
dockerfile: Dockerfile
</p>

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

关于azure - 无法拉取镜像 myapidemodocker.azurecr.io/apidemo :v4. 0:rpc 错误:代码 = 未知 desc = 未知 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50899387/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com