[英]microk8s pulling image, stuck in ContainerCreating state
As described in the doc (based on ). 如在所描述的文档 (基于上 )。
I am on Ubuntu as a host OS. 我在Ubuntu上作为主机操作系统。
docker --version
Docker version 18.09.6, build 481bc77
Docker版本18.09.6,build 481bc77
microk8s 1.14/beta
Enable local registry for microk2s
: 为
microk2s
启用本地注册表:
microk8s.enable registry
Checking: 检查:
watch microk8s.kubectl get all --all-namespaces
container-registry pod/registry-577986746b-v8xqc 1/1 Running 0 36m
container-registry pod / registry-577986746b-v8xqc 1/1运行0 36m
Then: 然后:
Edit: 编辑:
sudo vim /etc/docker/daemon.json
Add this content: 添加此内容:
{
"insecure-registries" : ["127.0.0.1:32000"]
}
Restart: 重新开始:
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
Tag: 标签:
docker tag my-registry/my-services/my-service:0.0.1-SNAPSHOT 127.0.0.1:32000/my-service
Checking: 检查:
docker images
127.0.0.1:32000/my-service latest e68f8a7e4675 19 hours ago 540MB
127.0.0.1:32000/my-service latest e68f8a7e4675 19小时前540MB
Pushing: 推动:
docker push 127.0.01:32000/my-service
I see my image here: http://127.0.0.1:32000/v2/_catalog 我在这里看到我的形象: http : //127.0.0.1 : 32000 / v2 / _catalog
In deployment-local.yml
I have, now the proper image: 在
deployment-local.yml
我有,现在正确的图像:
...spec:
containers:
- name: my-service-backend
image: 127.0.0.1:32000/my-service
imagePullPolicy: Always ...
Then applying: 然后申请:
envsubst < ./.local/deployment-local.yml | microk8s.kubectl apply -f -
I see: ContainerCreating
我明白了:
ContainerCreating
By: microk8s.kubectl describe pods my-service-deployment-f85d5dcd5-cmd5
通过:
microk8s.kubectl describe pods my-service-deployment-f85d5dcd5-cmd5
In the Events section: 在“事件”部分:
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. 好像我的服务卡在那里。
Q: What could be the reason? 问:可能是什么原因?
UPDATE: changing all to localhost
helped, meaning I could see now in the browser: http://localhost:32000/v2/_catalog . 更新:将所有更改为
localhost
帮助,这意味着我现在可以在浏览器中看到: http:// localhost:32000 / v2 / _catalog 。
{"repositories":["my-service"]}
But it worked only in Firefox.. weird. 但它只适用于Firefox ..很奇怪。 In chrome is pending..
在铬正在等待..
Still: 仍然:
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"
Seems it tries to connect by https.. 似乎它试图通过https连接..
-- -
Ok.. had to add the port for the yml image: part. 好的..必须添加yml图像的端口:部分。 will accept the answer below.
将接受以下答案。 Thanks.
谢谢。
In microk8s is a big different between localhost and 127.0.0.1 . 在microk8s中, localhost和127.0.0.1之间存在很大差异。 As you mentioned, you were based on this Stack case and there user were using localhost .
正如您所提到的,您基于此 Stack案例,并且用户正在使用localhost 。
The main issue here is error no available registry endpoint: failed to do request:
. 这里的主要问题是错误
no available registry endpoint: failed to do request:
。 It means microk8s cannot find endpoint. 这意味着microk8s找不到端点。
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"]
As you see in microk8s endpoint is localhost not 127.0.0.1 正如您在microk8s中看到的那样,端点是localhost而不是127.0.0.1
Please change image in deployment-local.yaml 请在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. 如果您遇到任何其他问题,请告诉我。
In my case I did not need tag and push image again with localhost, only change in YAML was required. 在我的情况下,我不需要标记和使用localhost再次推送图像,只需要更改YAML。
I also needed to comment out following line in the /etc/hosts (Ubuntu 18.04) 我还需要在/ etc / hosts中注释掉以下行(Ubuntu 18.04)
::1 localhost ip6-localhost
It seems that microk8s isn't capable of IPv6. 似乎microk8s不具备IPv6功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.