Microk8s 无法启动本地 docker 图像
Microk8s trouble launching local docker image
我在同一个虚拟机上使用最新版本的 microk8s 和 docker。 microk8s 注册表已启用。
我重新制作了我的图片 argus
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
argus 0.1 6d72b6be9981 3 hours ago 164MB
localhost:32000/argus registry 6d72b6be9981 3 hours ago 164MB
然后我推了
$ docker push localhost:32000/argus:registry
The push refers to repository [localhost:32000/argus]
c8a05c6fda3e: Pushed
5836f564d6a0: Pushed
9e3dd069b4a1: Pushed
6935b1ceeced: Pushed
d02e8e9f8523: Pushed
c5129c726314: Pushed
0f299cdf8fbc: Pushed
edaf6f6a5ef5: Pushed
9eb034f85642: Pushed
043895432150: Pushed
a26398ad6d10: Pushed
0dee9b20d8f0: Pushed
f68ef921efae: Pushed
registry: digest: sha256:0a0ac9e076e3249b8e144943026bc7c24ec47ce6559a4e087546e3ff3fef5c14 size: 3052
所有工作看起来都很好,但是当我尝试使用以下命令部署 pod 时:
$ microk8s kubectl create deployment argus --image=argus
deployment.apps/argus created
$ microk8s kubectl get pods
NAME READY STATUS RESTARTS AGE
argus-84c8dcc968-27nlz 0/1 ErrImagePull 0 9s
$ microk8s kubectl logs argus-84c8dcc968-27nlz
Error from server (BadRequest): container "argus" in pod "argus-84c8dcc968-27nlz" is waiting to start: trying and failing to pull image
图片无法拉取,我试过$ microk8s ctr images ls
但是这并没有告诉我任何信息。
那么我在这里做错了什么?
更新:
我尝试时这里有一点更新:
$ microk8s ctr image pull localhost:32000/argus:registry
ctr: failed to resolve reference "localhost:32000/argus:registry": failed to do request: Head "https://localhost:32000/v2/argus/manifests/registry": http: server gave HTTP response to HTTPS client
所以它似乎不喜欢它从我的本地存储库获得 http
响应。我查看了 /var/snap/microk8s/current/args/containerd-template.toml
的配置,localhost
存储库配置正确:
[plugins."io.containerd.grpc.v1.cri".registry]
# 'plugins."io.containerd.grpc.v1.cri".registry.mirrors' are namespace to mirror mapping for all namespaces.
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://registry-1.docker.io", ]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:32000"]
endpoint = ["http://localhost:32000"]
我在 centos8 虚拟机上 运行 所有这些。当我安装 docker
我需要用 sudo dnf install docker-ce --nobest
来做,否则会与 containerd 发生某种冲突,也许它必须对此做些什么?
你可以使用 kubectl describe 查看 pod
我猜它试图从 docker.io
中拉出“argus”
您是否尝试将 localhost:32000 添加到图像参数?
microk8s kubectl create deployment argus --image=localhost:32000/argus:registry
好的,这里有多个问题,我想我已经全部解决了。首先,我弄错了 Docker 图片。这是一个测试图像,但它应该有一些连续运行的东西,因为在 PID 1 结束后容器重新启动,原因是 microk8s/kubernetes
假设存在问题。这就是为什么会出现崩溃循环。
其次,要检查本地注册表中存在哪些存储库,最简单的方法是 curl
注册表的 rest API
:
$curl http://host:32000/v2/_catalog
获取所有图像的列表,并且:
$curl http://host:32000/v2/{repositoryName}/tags/list
获取给定存储库的所有标签。
最后,要手动从注册表拉取到集群而不出现 https
错误,有必要像这样添加 --plain-http
选项:
$microk8s ctr image pull --plain-http localhost:32000/repo:tag
我在同一个虚拟机上使用最新版本的 microk8s 和 docker。 microk8s 注册表已启用。
我重新制作了我的图片 argus
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
argus 0.1 6d72b6be9981 3 hours ago 164MB
localhost:32000/argus registry 6d72b6be9981 3 hours ago 164MB
然后我推了
$ docker push localhost:32000/argus:registry
The push refers to repository [localhost:32000/argus]
c8a05c6fda3e: Pushed
5836f564d6a0: Pushed
9e3dd069b4a1: Pushed
6935b1ceeced: Pushed
d02e8e9f8523: Pushed
c5129c726314: Pushed
0f299cdf8fbc: Pushed
edaf6f6a5ef5: Pushed
9eb034f85642: Pushed
043895432150: Pushed
a26398ad6d10: Pushed
0dee9b20d8f0: Pushed
f68ef921efae: Pushed
registry: digest: sha256:0a0ac9e076e3249b8e144943026bc7c24ec47ce6559a4e087546e3ff3fef5c14 size: 3052
所有工作看起来都很好,但是当我尝试使用以下命令部署 pod 时:
$ microk8s kubectl create deployment argus --image=argus
deployment.apps/argus created
$ microk8s kubectl get pods
NAME READY STATUS RESTARTS AGE
argus-84c8dcc968-27nlz 0/1 ErrImagePull 0 9s
$ microk8s kubectl logs argus-84c8dcc968-27nlz
Error from server (BadRequest): container "argus" in pod "argus-84c8dcc968-27nlz" is waiting to start: trying and failing to pull image
图片无法拉取,我试过$ microk8s ctr images ls
但是这并没有告诉我任何信息。
那么我在这里做错了什么?
更新:
我尝试时这里有一点更新:
$ microk8s ctr image pull localhost:32000/argus:registry
ctr: failed to resolve reference "localhost:32000/argus:registry": failed to do request: Head "https://localhost:32000/v2/argus/manifests/registry": http: server gave HTTP response to HTTPS client
所以它似乎不喜欢它从我的本地存储库获得 http
响应。我查看了 /var/snap/microk8s/current/args/containerd-template.toml
的配置,localhost
存储库配置正确:
[plugins."io.containerd.grpc.v1.cri".registry]
# 'plugins."io.containerd.grpc.v1.cri".registry.mirrors' are namespace to mirror mapping for all namespaces.
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://registry-1.docker.io", ]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:32000"]
endpoint = ["http://localhost:32000"]
我在 centos8 虚拟机上 运行 所有这些。当我安装 docker
我需要用 sudo dnf install docker-ce --nobest
来做,否则会与 containerd 发生某种冲突,也许它必须对此做些什么?
你可以使用 kubectl describe 查看 pod
我猜它试图从 docker.io
中拉出“argus”您是否尝试将 localhost:32000 添加到图像参数?
microk8s kubectl create deployment argus --image=localhost:32000/argus:registry
好的,这里有多个问题,我想我已经全部解决了。首先,我弄错了 Docker 图片。这是一个测试图像,但它应该有一些连续运行的东西,因为在 PID 1 结束后容器重新启动,原因是 microk8s/kubernetes
假设存在问题。这就是为什么会出现崩溃循环。
其次,要检查本地注册表中存在哪些存储库,最简单的方法是 curl
注册表的 rest API
:
$curl http://host:32000/v2/_catalog
获取所有图像的列表,并且:
$curl http://host:32000/v2/{repositoryName}/tags/list
获取给定存储库的所有标签。
最后,要手动从注册表拉取到集群而不出现 https
错误,有必要像这样添加 --plain-http
选项:
$microk8s ctr image pull --plain-http localhost:32000/repo:tag