“kubectl get pods”显示STATUS - ImagePullbackOff

问题描述 投票:1回答:2

我在我的机器上设置了一个自托管注册表来存储docker镜像文件,以便使用minikube(用于本地开发的轻量级Kubernetes实现)对其进行彻底测试。

虽然我能够使用docker push和docker pull命令从本地注册表成功推送和提取存储库,但在尝试在本地运行pod时,面临以下问题:

错误

Failed to pull image "localhost:5000/dev/customer:v1": rpc error: code = Unknown desc
= Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: getsockopt: connection refused

这是我在检查吊舱时发现的事件列表。

根据事件

Type     Reason                 Age                From               Message

----     ------                 ----               ----               -------

Normal   Scheduled              16m                default-scheduler  Successfully assigned custappdeployment-6c8ddcc5d8-2zdfn to minikube

Normal   SuccessfulMountVolume  16m                kubelet, minikube  MountVolume.SetUp succeeded for volume "default-token-s5nlw"

Normal   BackOff                16m (x2 over 16m)  kubelet, minikube  Back-off pulling image "localhost:5000/dev/customer:v1"

Warning  Failed                 16m (x2 over 16m)  kubelet, minikube  Error: ImagePullBackOff

Normal   Pulling                15m (x3 over 16m)  kubelet, minikube  pulling image "localhost:5000/dev/customer:v1"

Warning  Failed                 15m (x3 over 16m)  kubelet, minikube  Failed to pull image "localhost:5000/dev/customer:v1": rpc error: code = Unknown desc
= Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: getsockopt: connection refused

Warning  Failed                 15m (x3 over 16m)  kubelet, minikube  **Error: ErrImagePull**

Please see below the docker pull command output. 

PS C:\Sunny\Projects\NodeApps\Nodejs-Apps\Customer> docker pull localhost:5000/dev/customer:v1

v1: Pulling from dev/customer
Digest: sha256:edf0b716728b1cc00f7d8eed76fb3bdceadf1a60a46b9e4f80d983a64389e95c
Status: Image is up to date for localhost:5000/dev/customer:v1
docker kubernetes docker-registry minikube
2个回答
3
投票

好吧,我不希望你的localhostlocalhost的观点中的minikube相同。实际上,我不希望你的localhost与kubernetes世界中的任何东西都是同一个本地主机。

所以,你需要检查一些实用的东西:

  • 可以从非机器访问端口5000(意味着minikube虚拟机可能从您机器上的端口5000拉出) 这个问题可能与下面的要点有一些交集,因为您的注册表可能正在监听其中一个内部适配器,但这不是您的机器所知道的,或者相反
  • mininiube可以解析您的机器所呈现的主机名(因为我实际上认为您不能在docker镜像参考中使用IP地址);很明显,如果这个假设不正确,那么就不必担心这一部分了
  • 并确保docker要么不信任您的注册表CA,要么您已经将证书加载到minikube并弹回docker

你可以随时作弊,因为minikube是一个虚拟机(而不是一整套节点)和docker save $the_image_ref | minikube ssh docker load将完全支持拉力(除非你有imagePullPolicy: Always但很容易修复)。


1
投票

如果您使用私有docker注册表,请将注册表绑定到0.0.0.0,以便可以从其他服务器访问它。此外,如果其不安全的注册表,请将此URL添加到docker守护程序不安全的注册表列表中。

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