microk8s拉取图像,停留在ContainerCreating状态 [英] microk8s pulling image, stuck in ContainerCreating state

查看:500
本文介绍了microk8s拉取图像,停留在ContainerCreating状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

doc 中所述(基于我在Ubuntu上作为主机操作系统.

I am on Ubuntu as a host OS.

docker --version

Docker版本18.09.6,内部版本481bc77

Docker version 18.09.6, build 481bc77

microk8s 1.14/beta


microk2s启用本地注册表:


Enable local registry for microk2s:

microk8s.enable registry

检查:

watch microk8s.kubectl get all --all-namespaces

container-registry pod/registry-577986746b-v8xqc 1/1正在运行0 36m

container-registry pod/registry-577986746b-v8xqc 1/1 Running 0 36m

然后:

sudo vim /etc/docker/daemon.json

添加此内容:

{
  "insecure-registries" : ["127.0.0.1:32000"]
}

重新启动:

sudo systemctl restart docker

仔细检查,看看是否应用了不安全的方法:

Double checking, see if insecure is applied:

docker info | grep -A 2 Insecure

Insecure Registries:
 127.0.0.1:32000
 127.0.0.0/8
WARNING: No swap limit support

标签:

docker tag my-registry/my-services/my-service:0.0.1-SNAPSHOT 127.0.0.1:32000/my-service

检查:

docker images

127.0.0.1:32000/my-service最新e68f8a7e4675 19小时前540MB

127.0.0.1:32000/my-service latest e68f8a7e4675 19 hours ago 540MB

推动:

docker push 127.0.01:32000/my-service

我在这里看到我的图片: http://127.0.0.1:32000/v2/_catalog

I see my image here: http://127.0.0.1:32000/v2/_catalog

deployment-local.yml中,我现在拥有正确的图像:

In deployment-local.yml I have, now the proper image:

...spec:
  containers:
    - name: my-service-backend
      image: 127.0.0.1:32000/my-service
      imagePullPolicy: Always ...

然后申请:

envsubst < ./.local/deployment-local.yml | microk8s.kubectl apply -f -

我看到:ContainerCreating

通过:microk8s.kubectl describe pods my-service-deployment-f85d5dcd5-cmd5

在事件"部分:

Events:
  Type     Reason     Age                 From                     Message
  ----     ------     ----                ----                     -------
  Normal   Scheduled  107s                default-scheduler        Successfully assigned default/my-service-deployment-f85d5dcd5-z75tr to my-desktop
  Normal   Pulling    25s (x4 over 106s)  kubelet, my-desktop  Pulling image "127.0.0.1:32000/my-service"
  Warning  Failed     25s (x4 over 106s)  kubelet, my-desktop  Failed to pull image "127.0.0.1:32000/my-service": rpc error: code = Unknown desc = failed to resolve image "127.0.0.1:32000/my-service:latest": no available registry endpoint: failed to do request: Head https://127.0.0.1:32000/v2/my-service/manifests/latest: http: server gave HTTP response to HTTPS client
  Warning  Failed     25s (x4 over 106s)  kubelet, my-desktop  Error: ErrImagePull
  Normal   BackOff    10s (x5 over 105s)  kubelet, my-desktop  Back-off pulling image "127.0.0.1:32000/my-service"
  Warning  Failed     10s (x5 over 105s)  kubelet, my-desktop  Error: ImagePullBackOff

好像我的服务卡在那里了.

Seems like my-service is stuck there.

问:可能是什么原因?

更新: 将所有内容更改为localhost帮助,这意味着我现在可以在浏览器中看到: http://localhost:32000/v2 /_catalog .

UPDATE: changing all to localhost helped, meaning I could see now in the browser: http://localhost:32000/v2/_catalog .

{"repositories":["my-service"]}

但是它仅在Firefox中有效.在chrome中待处理..

But it worked only in Firefox.. weird. In chrome is pending..

还是:

Events:
  Type     Reason          Age                    From                    Message
  ----     ------          ----                   ----                    -------
  Normal   Scheduled       161m                   default-scheduler       Successfully assigned default/my-service-deployment-6d4c5587df-72xvd to my-laptop
  Normal   Pulling         160m (x4 over 161m)    kubelet, my-laptop  Pulling image "localhost/my-service"
  Warning  Failed          160m (x4 over 161m)    kubelet, my-laptop  Failed to pull image "localhost/my-service": rpc error: code = Unknown desc = failed to resolve image "localhost/my-service:latest": no available registry endpoint: failed to do request: Head https://localhost/v2/my-service/manifests/latest: dial tcp 127.0.0.1:443: connect: connection refused
  Warning  Failed          160m (x4 over 161m)    kubelet, my-laptop  Error: ErrImagePull
  Warning  Failed          159m (x6 over 161m)    kubelet, my-laptop  Error: ImagePullBackOff
  Normal   BackOff         131m (x132 over 161m)  kubelet, my-laptop  Back-off pulling image "localhost/my-service"
  Normal   SandboxChanged  22m                    kubelet, my-laptop  Pod sandbox changed, it will be killed and re-created.
  Normal   Pulling         21m (x4 over 22m)      kubelet, my-laptop  Pulling image "localhost/my-service"
  Warning  Failed          21m (x4 over 22m)      kubelet, my-laptop  Failed to pull image "localhost/my-service": rpc error: code = Unknown desc = failed to resolve image "localhost/my-service:latest": no available registry endpoint: failed to do request: Head https://localhost/v2/my-service/manifests/latest: dial tcp 127.0.0.1:443: connect: connection refused
  Warning  Failed          21m (x4 over 22m)      kubelet, my-laptop  Error: ErrImagePull
  Warning  Failed          20m (x6 over 22m)      kubelet, my-laptop  Error: ImagePullBackOff
  Normal   BackOff         2m22s (x87 over 22m)   kubelet, my-laptop  Back-off pulling image "localhost/my-service"

似乎它尝试通过https连接.

Seems it tries to connect by https..

-

好..必须添加yml image:部分的端口.将接受下面的答案.谢谢.

Ok.. had to add the port for the yml image: part. will accept the answer below. Thanks.

推荐答案

在microk8s中, localhost 127.0.0.1 之间有很大的不同.如您所述,您基于的是堆栈大小写,那里的用户正在使用 localhost .

In microk8s is a big different between localhost and 127.0.0.1. As you mentioned, you were based on this Stack case and there user were using localhost.

这里的主要问题是错误no available registry endpoint: failed to do request:.这意味着microk8无法找到端点.

The main issue here is error no available registry endpoint: failed to do request:. It means microk8s cannot find endpoint.

如果您在下面进行推荐,您将获得相同的输出

If you will run commend below, you will have the same output

$ cat /var/snap/microk8s/current/args/containerd-template.toml | grep endpoint

endpoint = ["https://registry-1.docker.io"]
endpoint = ["http://localhost:32000"]

您在microk8s端点中看到的是 localhost 而不是127.0.0.1

As you see in microk8s endpoint is localhost not 127.0.0.1

请在Deployment-local.yaml中更改映像

Please change image in deployment-local.yaml

...spec:
  containers:
    - name: my-service-backend
      image: localhost/my-service
      imagePullPolicy: Always ...

让我知道您是否还会发生其他任何问题.

Let me know if you will occur any other issues.

在我的情况下,我不需要标记并使用localhost再次推送图像,只需要更改YAML.

In my case I did not need tag and push image again with localhost, only change in YAML was required.

这篇关于microk8s拉取图像,停留在ContainerCreating状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆