注意:此架构有缺陷不适合用于生产,只作为学习
因为安装harbor需要用到docker,所以请先安装docker
这一步内容请看docker安装
wget https://github.com/goharbor/harbor/releases/download/v2.5.6/harbor-offline-installer-v2.5.6.tgz
如果网速慢,本文提供一个免费下载的包harbor-v2.5.6
tar xf harbor-offline-installer-v2.5.6.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
vim harbor.yml# 配置文件内容,IP192.168.10.3改成对应IP
hostname: 192.168.10.2
harbor_admin_password: Harbor12345
# https相关内容注释
#https:# https port for harbor, default is 443# port: 443# The path of cert and key files for nginx# certificate: /your/certificate/path# private_key: /your/private/key/path
./install.sh
192.168.10.2
192.168.10.3
点击系统管理——》仓库管理——》新建目标——》填写信息——》测试连接——》成功点确定
点击系统管理——》复制管理——》新建规则——》填写信息——》保存
在02上进行类似的配置
yum -y install haproxy
[root@localhost ~]# unzip 9486797_harbor.yyang.top_nginx.zip
Archive: 9486797_harbor.yyang.top_nginx.zip
Aliyun Certificate Downloadinflating: 9486797_harbor.yyang.top.pem inflating: 9486797_harbor.yyang.top.key
[root@localhost ~]# mkdir /ssl
[root@localhost ~]# cat 9486797_harbor.yyang.top.pem >/ssl/harbor.pem
[root@localhost ~]# cat 9486797_harbor.yyang.top.key >>/ssl/harbor.pem
配置haproxy,添加以下内容
vim /etc/haproxy/haproxy.cfg
frontend harborbind *:80bind *:443 ssl crt /ssl/harbor.pemmode httpuse_backend harbor_clusterredirect scheme https if !{ ssl_fc }http-request set-header X-Forwarded-Proto http if !{ ssl_fc }http-request set-header X-Forwarded-Proto https if { ssl_fc }backend harbor_clusterbalance sourceserver harbor-01 192.168.10.2:80 check port 80server harbor-02 192.168.10.3:80 check port 80
systemctl start haproxy.service
systemctl enable haproxy.service
echo "192.168.10.4 harbor.yyang.top" >>/etc/hosts
docker pull busybox
docker images
busybox latest beae173ccac6 14 months ago 1.24MB
docker tag beae173ccac6 harbor.yyang.top/test/busybox
docker push harbor.yyang.top/test/busybox:latest
The push refers to repository [harbor.yyang.top/test/busybox]
01fd6df81c8e: Pushed
latest: digest: sha256:62ffc2ed7554e4c6d360bce40bbcf196573dd27c4ce080641a2c59867e732dee size: 527
注意:次架构不能同步用户级别镜像。只能使用admin。