Harbor
定位: 企业级的docker镜像仓库
私有仓库: registry,存镜像
Harbor是对私有仓库包装之上形成的更高级、更好用的,私有库其实是harbor内置的一个组件
整体的角色:
Proxy:代理,harbor内置的一个nginx,做反向代理
Registry:私有仓库,作用:主要负责对来自客户端docker库的指令来进行解析(docker pull拉取镜像、下载镜像,docker push上传镜像)
Core services:核心服务区
Ui:ui界面,可视化界面
Token:组件,来负责验证。登录ui界面,需要token验证
webhook:进行通讯。类似于api接口
database:存储镜像的数据(镜像的数据分为两种:1.元数据:描述数据的数据2.普通数据:镜像里的小组件)
job services:harbor也具有主从关系,让镜像能够在主从或多个harbor之间进行同步,进行harbor之间镜像的传输
log collector:收集全局的日志
环境:
主机 | ip |
---|---|
服务端 | 192.168.10.20 |
客户端 | 192.168.10.30 |
安装docker(两台都要安装)
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2021-01-18 12:14:05-- http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost ~]# yum -y install docker-ce
[root@localhost ~]# systemctl start docker
客户端:
[root@localhost ~]# docker pull hello-world
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 12 months ago 13.3kB
服务端:
拖入软件包并重启docker
[root@localhost ~]# ls
harbor-offline-installer-v1.6.2.tgz docker-compose
[root@localhost ~]# systemctl restart docker
安装harbor服务
[root@localhost ~]# tar -zxf harbor-offline-installer-v1.6.2.tgz -C /usr/local
[root@localhost ~]# cd /usr/local/harbor/
[root@localhost harbor]# vim harbor.cfg
7 hostname = 192.168.10.20
[root@localhost harbor]# cd
[root@localhost ~]# mv docker-compose /usr/bin/
[root@localhost ~]# chmod +x /usr/bin/docker-compose
[root@localhost ~]# cd /usr/local/harbor/
[root@localhost harbor]# ./install.sh
………………
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.10.20.
For more details, please visit https://github.com/goharbor/harbor .
访问192.168.10.20:80
创建一个项目
客户端:
[root@localhost ~]# docker tag hello-world:latest 192.168.10.20/kgcweb/hello-world
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.10.20/kgcweb/hello-world latest bf756fb1ae65 12 months ago 13.3kB
hello-world latest bf756fb1ae65 12 months ago 13.3kB
[root@localhost ~]# vim /usr/lib/systemd/system/docker.service
#修改
13 ExecStart=/usr/bin/dockerd --insecure-registry 192.168.10.20 #指定harbor私服
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# docker login -u admin -p Harbor12345 192.168.10.20
…………
Login Succeeded
[root@localhost ~]# docker push 192.168.10.20/kgcweb/hello-world
Using default tag: latest
The push refers to repository [192.168.10.20/kgcweb/hello-world]
9c27e219663c: Pushed
latest: digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042 size: 525
服务端查看
harbor主从
环境:
主机 | ip |
---|---|
harbor主 | 192.168.10.20 |
harbor从 | 192.168.10.30 |
两台都要安装docker环境(上面写过)
主从也都要安装harbor服务
[root@localhost ~]# tar -zxf harbor-offline-installer-v1.6.2.tgz -C /usr/local
[root@localhost ~]# cd /usr/local/harbor/
[root@localhost harbor]# vim harbor.cfg
7 hostname = 192.168.10.20 #本机的ip
[root@localhost harbor]# cd
[root@localhost ~]# mv docker-compose /usr/bin/
[root@localhost ~]# chmod +x /usr/bin/docker-compose
[root@localhost ~]# cd /usr/local/harbor/
[root@localhost harbor]# ./install.sh
………………
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.10.20.
For more details, please visit https://github.com/goharbor/harbor .
安装完成之后两台分别去访问自己的页面
默认用户名和密码:admin Harbor12345
harbor主:
新建目标并测试连接
新建规则
harbor从主机上进行验证查看
可以看到数据已经同步到了从上面
实验完成