转 kubernetes(k8s)第四部分之配置本地镜像仓库

【1】获取registry镜像

在一台能上网并且安装docker的主机上通过pull获取registry镜像。

[root@random ~]# docker pull registry

【2】获取pod-infrastructure镜像

该镜像是在node节点创建pod时必须要有的。通过search你可以看到很多包含该名称的镜像,我下载的是下图标记的镜像。

[root@random ~]# docker search pod-infrastructure

将镜像pull到本地。

[root@random ~]# docker  pull  tianyebj/pod-infrastructure

[root@random docker]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                                 latest              d1fd7d86a825        4 months ago        33.26 MB
tianyebj/pod-infrastructure   latest              34d3450d733b        16 months ago       205 MB
【3】将镜像保存为tar包并发送给master节点

[root@random ~]# docker save -o pod-infrastructure.tar tianyebj/pod-infrastructure

[root@random ~]# docker save -o registry.tar registry

[root@random ~]# ls

pod-infrastructure.tar  registry.tar

[root@random ~]# scp pod-infrastructure.tar registry.tar [email protected]:

【4】在master节点将镜像load

[root@k8s-master ~]# docker load -i registry.tar

[root@k8s-master ~]# docker load -i pod-infrastructure.tar

[root@k8s-master ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                      latest              d1fd7d86a825        4 months ago        33.3 MB
tianyebj/pod-infrastructure   latest              34d3450d733b        16 months ago       205 MB
【5】将pod-infrastructure镜像存入仓库,node节点拉取镜像

启动私有仓库:

[root@k8s-master ~]# docker run -d -p 5000:5000 --name=registry --restart=always --privileged=true  --log-driver=none -v /home/data/registrydata:/tmp/registry registry
其中,/home/data/registrydata是一个比较大的系统分区,今后镜像仓库中的全部数据都会保存在这个外挂目录下。

镜像重命名:

[root@k8s-master docker]# docker tag  tianyebj/pod-infrastructure  registry:5000/pod-infrastructure

镜像push到私有仓库:

[root@k8s-master docker]# docker  push  registry:5000/pod-infrastructure

Node节点拉取镜像:

[root@k8s-node1 docker]# docker  pull  registry:5000/pod-infrastructure

[root@k8s-node2 docker]# docker  pull  registry:5000/pod-infrastructure
--------------------- 
作者:random_w 
来源:CSDN 
原文:https://blog.csdn.net/random_w/article/details/80602131 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/lj88811498/article/details/89333850