码迷,mamicode.com
首页 > 其他好文 > 详细

02:配置k8s-master为镜像仓库

时间:2019-11-16 23:10:56      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:nal   ima   -name   loss   com   find   enable   insecure   ttl   

配置master为镜像仓库

#master节点

#替换配置文件中的这行,使用下面的内容
#配置docker加速,和信任私有仓库(注意,系统自带或者我们后安装的docker版本,配置文件是/etc/docker/daemon.jason)
[root@k8s-master ~]#vim /etc/sysconfig/docker
OPTIONS=‘--selinux-enabled --log-driver=journald --signature-verification=false --registry-mirror=https://aeckruos.mirror.aliyuncs.com --insecure-registry=192.168.6.129:5000‘

#重启docker
[root@k8s-master ~]#systemctl restart docker

#起仓库容器(普通的registry) 前面docker文件里面有单独一遍讲解如何安装registry,这里不在描述
[root@k8s-master ~]# docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry registry
Unable to find image ‘registry:latest‘ locally
Trying to pull repository docker.io/library/registry ...
latest: Pulling from docker.io/library/registry

c87736221ed0: Pull complete
1cc8e0bb44df: Pull complete
54d33bcb37f5: Pull complete
e8afc091c171: Pull complete
b4541f6d3db6: Pull complete
Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
917d5def661733464c5039695917255b0270cb28f4173c450374734c7298b00a
[root@k8s-master ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/busybox latest 020584afccce 2 weeks ago 1.22 MB
docker.io/registry latest f32a97de94e1 8 months ago 25.76 MB

#上传一个镜像到私有仓库
[root@k8s-master ~]# docker tag docker.io/busybox:latest 192.168.6.129:5000/busybox:latest

----------
#node节点(镜像加速,信任129registry仓库)
[root@k8s-node-1 ~]#vim /etc/sysconfig/docker
OPTIONS=‘--selinux-enabled --log-driver=journald --signature-verification=false --registry-mirror=https://aeckruos.mirror.aliyuncs.com --insecure-registry=192.168.6.129:5000‘
[root@k8s-node-2 ~]#vim /etc/sysconfig/docker
OPTIONS=‘--selinux-enabled --log-driver=journald --signature-verification=false --registry-mirror=https://aeckruos.mirror.aliyuncs.com --insecure-registry=192.168.6.129:5000‘
[root@k8s-node-1 ~]#

#重启docker
[root@k8s-node-1 ~]#systemctl restart docker
[root@k8s-node-1 ~]#systemctl restart docker

#测试,从主master 129仓库pull 下载镜像
#node-1
[root@k8s-node-1 ~]# docker pull 192.168.6.129:5000/busybox:latest
Trying to pull repository 192.168.6.129:5000/busybox ...
latest: Pulling from 192.168.6.129:5000/busybox
Digest: sha256:679b1c1058c1f2dc59a3ee70eed986a88811c0205c8ceea57cec5f22d2c3fbb1
[root@k8s-node-1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.6.129:5000/busybox latest 020584afccce 2 weeks ago 1.22 MB
docker.io/busybox latest 020584afccce 2 weeks ago 1.22 MB
#node-2
[root@k8s-node-2 ~]# docker pull 192.168.6.129:5000/busybox:latest
Trying to pull repository 192.168.6.129:5000/busybox ...
latest: Pulling from 192.168.6.129:5000/busybox
Digest: sha256:679b1c1058c1f2dc59a3ee70eed986a88811c0205c8ceea57cec5f22d2c3fbb1
[root@k8s-node-2 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.6.129:5000/busybox latest 020584afccce 2 weeks ago 1.22 MB
docker.io/busybox latest 020584afccce 2 weeks ago 1.22 MB
[root@k8s-node-2 ~]#

仓库搭好了。
===============================
再次确认k8s三台的起的容器能网络是通的:
[root@k8s-master ~]# docker run -it busybox /bin/sh #三台都起一个容器,互相ping
/ # ping 172.16.16.2
PING 172.16.16.2 (172.16.16.2): 56 data bytes
^C
--- 172.16.16.2 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.538/0.824/1.728 ms
/ # ^C
/ # ping 172.16.83.2
PING 172.16.83.2 (172.16.83.2): 56 data bytes
64 bytes from 172.16.83.2: seq=0 ttl=60 time=1.453 ms
^C
--- 172.16.83.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.453/1.453/1.453 ms
/ #

 

 

02:配置k8s-master为镜像仓库

标签:nal   ima   -name   loss   com   find   enable   insecure   ttl   

原文地址:https://www.cnblogs.com/jim-xu/p/11874315.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!