简体   繁体   English

“kubectl get pods”显示状态 - ImagePullbackOff

[英]“kubectl get pods” showing STATUS - ImagePullbackOff

I setup a self-hosted registry on my machine to store the docker image files to test it thoroughly using minikube (lightweight Kubernetes implementation for local development).我在我的机器上设置了一个自托管注册表来存储docker图像文件,以使用minikube (用于本地开发的轻量级 Kubernetes 实现)对其进行彻底测试。

Though I'm able to successfully push & pull repositories from local registry using docker push and docker pull commands but while trying to run a pod locally, facing below issue :虽然我能够使用docker pushdocker pull命令从本地注册表成功推送和拉取存储库,但是在尝试在本地运行 pod 时,面临以下问题:

Error错误

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

Here's the list of events I noticed while inspecting the pod.这是我在检查 pod 时注意到的事件列表。

Pod Events Pod 事件

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

Well, I wouldn't expect your localhost to be the same as localhost from minikube 's point-of-view.好吧,从minikube的角度来看,我不希望您的localhostlocalhost相同。 Actually, I wouldn't expect your localhost to be the same localhost from anything in the kubernetes world's point-of-view.其实,我不希望你的本地主机是从kubernetes世界的角度的视图任何同本地主机。

So, some practical things you'll want to check:所以,你需要检查一些实际的东西:

  • is port 5000 accessible from not-your-machine (meaning could the minikube virtual machine plausibly pull from port 5000 on your machine)端口 5000 是否可从非您的机器访问(这意味着 minikube 虚拟机可能从您机器上的端口 5000 中拉取)

    this question likely has some intersection with the point right below, because your registry may very well be listening on one of the internal adapters, but that's not what your machine knows itself as, or the opposite这个问题可能与下面的点有一些交集,因为您的注册表很可能正在侦听内部适配器之一,但这不是您的机器所知道的,或者相反

  • can minikube resolve the hostname that your machine presents itself as (because I actually don't think you can use an IP address in a docker image reference); minikube 能否解析您的机器显示的主机名(因为我实际上认为您不能在 docker 图像参考中使用 IP 地址); obviously if that assumption isn't true, then no need to worry about this part显然,如果该假设不正确,那么就无需担心这部分

  • and be sure that docker either is untrusting of your registry's CA, or you have already loaded the cert onto minikube and bounced docker并确保 docker 不信任您的注册表的 CA,或者您已经将证书加载到 minikube 上并退回了 docker

You can always cheat, since minikube is one virtual machine (and not a whole fleet of Nodes) and docker save $the_image_ref | minikube ssh docker load你总是可以作弊,因为 minikube 是一个虚拟机(而不是整个节点)和docker save $the_image_ref | minikube ssh docker load docker save $the_image_ref | minikube ssh docker load which will side-step the pull entirely (unless you have imagePullPolicy: Always but that's easily fixed). docker save $the_image_ref | minikube ssh docker load这将完全imagePullPolicy: Always拉动(除非你有imagePullPolicy: Always但那很容易修复)。

If you are using private docker registry, bind registry to 0.0.0.0 so it is accessible from other servers.如果您使用私有 docker 注册表,请将注册表绑定到0.0.0.0以便可以从其他服务器访问它。 Also if its insecure registry, add this URL to docker daemon insecure registries list.此外,如果它的注册表不安全,请将此 URL 添加到 docker daemon 不安全注册表列表。

I used the following steps to fix the issue..我使用以下步骤来解决这个问题..

  1. Double check the tag names, make sure they are consistent仔细检查标签名称,确保它们一致

  2. Build the image locally, making sure to tag it在本地构建图像,确保标记它

  3. Push the image to docker hub将镜像推送到 docker hub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM