如何在 k8s 集群中设置 docker 注册表?
How to setup docker registry in k8s cluster?
不需要安全注册。我只需要使用 http 协议连接到注册表。
注册表必须在 pod 上,而不是直接在 VM 上。
docker 有 registry
图像是专门为此目的制作的,但是当我在 pod 中使用它时,docker 无法与它通信,因为它认为它是安全注册表:
> docker pull 192.168.64.3:31549/repo630444582240256/image1
Using default tag: latest
Error response from daemon: Get https://192.168.64.3:31549/v2/: http: server gave HTTP response to HTTPS client
我遇到了这些解决方案,但每个解决方案都需要在 VM 中安装先决条件,或者不使用 pod 来设置注册表:
- https://github.com/SeldonIO/k8s-local-docker-registry
- https://github.com/alexellis/k8s-tls-registry
- https://github.com/ContainerSolutions/trow
> set -x && curl -X GET 192.168.64.3:31549/v2/_catalog
+ curl -X GET 192.168.64.3:31549/v2/_catalog
{"repositories":[]}
我在我的本地机器上试过这个:https://github.com/SeldonIO/k8s-local-docker-registry and works like a charm. (I had to make a few changes to the K8s manifests so they support the latest K8s)
您可以使用 curl -X GET 192.168.64.3:31549/v2/_catalog
访问注册表,这意味着没有重定向到 https。
我认为您的 docker 客户端配置没有针对 192.168.x.x
的显式 Insecure Registry
配置。您可以查看:
$ docker info | grep -i -A5 'Insecure Registries'
Insecure Registries:
10.96.0.0/12
127.0.0.0/8
192.168.64.0/24 <== should have something like this
如果没有,您可以在 daemon.json
配置中将 192.168.0.0/24
配置为 insecure registry:
{
"insecure-registries" : ["10.96.0.0/12", "127.0.0.0/8", "192.168.64.0/24" ]
}
刚发现另一条路径,您可以在其中添加不安全的注册表
$ vi /var/lib/boot2docker/profile
添加以下内容
EXTRA_ARGS='
--label provider=virtualbox
--insecure-registry 127.0.0.0/8
--insecure-registry 192.168.99.0/24
'
重启docker守护进程
$ /etc/init.d/docker restart
不需要安全注册。我只需要使用 http 协议连接到注册表。
注册表必须在 pod 上,而不是直接在 VM 上。
docker 有 registry
图像是专门为此目的制作的,但是当我在 pod 中使用它时,docker 无法与它通信,因为它认为它是安全注册表:
> docker pull 192.168.64.3:31549/repo630444582240256/image1
Using default tag: latest
Error response from daemon: Get https://192.168.64.3:31549/v2/: http: server gave HTTP response to HTTPS client
我遇到了这些解决方案,但每个解决方案都需要在 VM 中安装先决条件,或者不使用 pod 来设置注册表:
- https://github.com/SeldonIO/k8s-local-docker-registry
- https://github.com/alexellis/k8s-tls-registry
- https://github.com/ContainerSolutions/trow
> set -x && curl -X GET 192.168.64.3:31549/v2/_catalog
+ curl -X GET 192.168.64.3:31549/v2/_catalog
{"repositories":[]}
我在我的本地机器上试过这个:https://github.com/SeldonIO/k8s-local-docker-registry and works like a charm. (I had to make a few changes to the K8s manifests so they support the latest K8s)
您可以使用 curl -X GET 192.168.64.3:31549/v2/_catalog
访问注册表,这意味着没有重定向到 https。
我认为您的 docker 客户端配置没有针对 192.168.x.x
的显式 Insecure Registry
配置。您可以查看:
$ docker info | grep -i -A5 'Insecure Registries'
Insecure Registries:
10.96.0.0/12
127.0.0.0/8
192.168.64.0/24 <== should have something like this
如果没有,您可以在 daemon.json
配置中将 192.168.0.0/24
配置为 insecure registry:
{
"insecure-registries" : ["10.96.0.0/12", "127.0.0.0/8", "192.168.64.0/24" ]
}
刚发现另一条路径,您可以在其中添加不安全的注册表
$ vi /var/lib/boot2docker/profile
添加以下内容
EXTRA_ARGS='
--label provider=virtualbox
--insecure-registry 127.0.0.0/8
--insecure-registry 192.168.99.0/24
'
重启docker守护进程
$ /etc/init.d/docker restart