前置条件:安装 docker-compose
curl -L "https://get.daocloud.io/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose
下载 Harbor-1.6.0
https://github.com/goharbor/harbor/releases?page=14
在2台 work 节点上下载并解压该文件
tar zxvf harbor.tar.gz
修改 harbor.cfg
#The IP address or hostname to access admin UI and registry service.#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.# hostname 改成当前work节点ip,因为部署高可用集群不方便解析域名hostname = 192.168.109.13##The initial password of Harbor admin, only works for the first time when Harbor starts.#It has no effect after the first launch of Harbor.#Change the admin password from UI after launching Harbor.# 登录 harbor dashboard 的密码harbor_admin_password = root
执行 install.sh
[root@s1 harbor]# ./install.sh......[Step 4]: starting Harbor ...Creating network "harbor_harbor" with the default driverCreating harbor-log ... doneCreating registry ... doneCreating harbor-adminserver ... doneCreating redis ... doneCreating harbor-db ... doneCreating harbor-ui ... doneCreating harbor-jobservice ... doneCreating nginx ... done✔ ----Harbor has been installed and started successfully.----Now you should be able to visit the admin portal at http://192.168.109.14.For more details, please visit https://github.com/goharbor/harbor .
访问 harbor dashboard
http://192.168.109.14
admin / root
在 master 节点上安装 Nginx
docker pull nginx:1.13.12
编写四层代理配置
mkdir nginxcd nginxvim nginx.confpwd/root/nginx
user nginx;worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events {worker_connections 1024;}stream {upstream hub {server 192.168.109.13:80;# server 192.168.109.13:443;}server {listen 80;# listen 443;proxy_pass hub;proxy_timeout 300s;proxy_connect_timeout 5s;}}
编写 restart.sh
#!/bin/bash# 停止 harbornginxdocker stop harbornginx# 参数 harbornginxdocker rm harbornginx# 运行 harbornginx,并且挂载 nginx.conf 文件:/root/nginx/nginx.conf:/etc/nginx/nginx.confdocker run -idt --net=host --name harbornginx -v /root/nginx/nginx.conf:/etc/nginx/nginx.conf nginx:1.13.12
执行 restart.sh
chmod +x restart.sh
使用 master 节点 ip 访问 harbor dashboard
http://192.168.109.10
admin / root
