前置条件:安装 docker-compose

  1. curl -L "https://get.daocloud.io/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  2. chmod +x /usr/local/bin/docker-compose

下载 Harbor-1.6.0

https://github.com/goharbor/harbor/releases?page=14

在2台 work 节点上下载并解压该文件

  1. tar zxvf harbor.tar.gz

修改 harbor.cfg

  1. #The IP address or hostname to access admin UI and registry service.
  2. #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
  3. # hostname 改成当前work节点ip,因为部署高可用集群不方便解析域名
  4. hostname = 192.168.109.13
  5. ##The initial password of Harbor admin, only works for the first time when Harbor starts.
  6. #It has no effect after the first launch of Harbor.
  7. #Change the admin password from UI after launching Harbor.
  8. # 登录 harbor dashboard 的密码
  9. harbor_admin_password = root

执行 install.sh

  1. [root@s1 harbor]# ./install.sh
  2. ...
  3. ...
  4. [Step 4]: starting Harbor ...
  5. Creating network "harbor_harbor" with the default driver
  6. Creating harbor-log ... done
  7. Creating registry ... done
  8. Creating harbor-adminserver ... done
  9. Creating redis ... done
  10. Creating harbor-db ... done
  11. Creating harbor-ui ... done
  12. Creating harbor-jobservice ... done
  13. Creating nginx ... done
  14. ----Harbor has been installed and started successfully.----
  15. Now you should be able to visit the admin portal at http://192.168.109.14.
  16. For more details, please visit https://github.com/goharbor/harbor .

访问 harbor dashboard

http://192.168.109.14
admin / root

在 master 节点上安装 Nginx

  1. docker pull nginx:1.13.12

编写四层代理配置

  1. mkdir nginx
  2. cd nginx
  3. vim nginx.conf
  4. pwd
  5. /root/nginx
  1. user nginx;
  2. worker_processes 1;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. stream {
  9. upstream hub {
  10. server 192.168.109.13:80;
  11. # server 192.168.109.13:443;
  12. }
  13. server {
  14. listen 80;
  15. # listen 443;
  16. proxy_pass hub;
  17. proxy_timeout 300s;
  18. proxy_connect_timeout 5s;
  19. }
  20. }

编写 restart.sh

  1. #!/bin/bash
  2. # 停止 harbornginx
  3. docker stop harbornginx
  4. # 参数 harbornginx
  5. docker rm harbornginx
  6. # 运行 harbornginx,并且挂载 nginx.conf 文件:/root/nginx/nginx.conf:/etc/nginx/nginx.conf
  7. docker run -idt --net=host --name harbornginx -v /root/nginx/nginx.conf:/etc/nginx/nginx.conf nginx:1.13.12

执行 restart.sh

  1. chmod +x restart.sh

使用 master 节点 ip 访问 harbor dashboard

http://192.168.109.10
admin / root