harbor-v2.2.2 高可用 HTTPS部署

介绍

    vmware 官方开源服务器列表地址: https://vmware.github.io/harbor/cn/

    harbor 官方 github 地址: https://github.com/vmware/harbor/

    harbor 官方网址: https://goharbor.io/

    Harbor是一个用于存储和分发Docker镜像的企业级 Registry 服务器, 由 vmware 开源, 通过添加一些企业必须的功能特性, 例如安全, 标识和管理等. 扩展了开源Docker Distribution. 作为一个企业级私有 Registry 服务器, Harbor 提供了更好的性能和安全, 提升用户使用Registry构建和运行环境传输镜像的效率, Harbor 支持安装在多个 Registry 节点的镜像资源复制, 镜像全部保存在私有 Registry 中, 确保数据和支持产权在公司内部网络中管控, 另外, Harbor 也提供了高级的安全性, 例如用户管理, 访问控制和活动审计等.

 

 

 harbor 功能介绍

  • 基于角色访问控制, 用户与 Docker 镜像仓库通过项目进行组织管理, 一个用户可以对多个项目仓库在同一命名空间 project 里有不同的权限,
  • 镜像复制: 镜像可以在多个 Registry 实例中复制同步, 尤其适合于负载均衡,高可用, 混合云和多云的场景.
  • 图形化用户界面: 用户可以通过浏览器来浏览, 检索当前Docker镜像仓库, 管理项目和命名空间,
  • AD\LDAP支持: Harbor 可以继承企业内部已有的AD/LDAP, 用于鉴权认证管理,
  • 审计管理: 所有针对镜像仓库的操作都可以被记录追溯, 用于审计管理.
  • 国际化, 目前拥有中文, 英文, 德文, 日文, 和俄文的本地化版本更多语言将会添加进来.
  • RESTful API: 提供给管理员对Harbor 更多的操控, 是的与其他管理软件继承变得更容易.
  • 部署简单: 提供在线和离线两种安装工具, 也可以安装到 Vsphere 平台(OVA 方式) 虚拟化设备.

harbor 组件介绍

  • nginx: harbor 的一个反向代理组件, 代理 Registry, ui, token等服务, 这个代理会转发 harbor web 和 docker client 的各种请求到后端服务器上.
  • harbor-adminserver: harbor 系统管理接口, 可能修改系统配置以及获取系统信息.
  • harbor-db: 存储项目的元数据, 用户, 规则, 赋值策略等信息
  • harbor-jobservice: harbor 里面主要是为了镜像仓库之前同步使用的.
  • harbor-log: 手机其他harbor的日志信息.
  • harbor-ui: 一个用户界面模块, 用来管理 registry.
  • registry: 储存 docker images 的服务. 并且提供 pull/push服务.
  • regis: 储存缓存信息.
  • webhook: 当 registry 中的 image 状态发生变化的时候区记录更新日志, 复制等操作.
  • token service: 在 docker client 进行 pull/push 的时候负责 token 的发送.

基于http方式高可用部署

下载软件并解压

1 [root@ops110 ~]# cd /opt
2 [root@ops110 ops]# wget https://github.com/goharbor/harbor/releases/download/v2.2.2/harbor-offline-installer-v2.2.2.tgz
3 [root@ops110 ops]# tar xf harbor-offline-installer-v2.2.2.tgz 
4 [root@ops110 ops]# cd harbor/

修改配置文件并配置

 1 root@k8s207:/opt/harbor# cat harbor.yml | grep -Ev "^#|^$|^.*#"
 2 hostname: 172.16.0.207
 3 http:
 4   port: 8888
 5 harbor_admin_password: devops
 6 database:
 7   password: root123
 8   max_idle_conns: 50
 9   max_open_conns: 1000
10 data_volume: /data/harbor
11 trivy:
12   ignore_unfixed: false
13   skip_update: false
14   insecure: false
15 jobservice:
16   max_job_workers: 10
17 notification:
18   webhook_job_max_retry: 10
19 chart:
20   absolute_url: disabled
21 log:
22   level: info
23   local:
24     rotate_count: 50
25     rotate_size: 200M
26     location: /var/log/harbor
27 _version: 2.2.0
28 proxy:
29   http_proxy:
30   https_proxy:
31   no_proxy:
32   components:
33     - core
34     - jobservice
35     - trivy
36 root@k8s207:/opt/harbor# ./install.sh 

haproxy配置文件

 1 root@k8s207:/opt/harbor# cat /etc/haproxy/haproxy.cfg 
 2 global
 3         log 127.0.0.1   local2
 4         log /dev/log    local1 notice
 5         chroot /var/lib/haproxy
 6         stats socket /run/haproxy/admin.sock mode 660 level admin
 7         stats timeout 30s
 8         user haproxy
 9         group haproxy
10         daemon
11  
12         # Default SSL material locations
13     #    ca-base /etc/ssl/certs
14      #   crt-base /etc/ssl/private
15  
16         # Default ciphers to use on SSL-enabled listening sockets.
17         # For more information, see ciphers(1SSL). This list is from:
18         #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
19       #  ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
20        # ssl-default-bind-options no-sslv3
21  
22 defaults
23         log     global
24         mode    tcp
25         option  httplog
26         option  dontlognull
27         retries 3
28         timeout http-request    10s
29         timeout queue           1m
30         timeout connect         10s
31         timeout client          1m
32         timeout server          1m
33         timeout http-keep-alive 10s
34         timeout check           10s
35         maxconn                 600
36         timeout connect 5000
37         timeout client  50000
38         timeout server  50000
39         errorfile 400 /etc/haproxy/errors/400.http
40         errorfile 403 /etc/haproxy/errors/403.http
41         errorfile 408 /etc/haproxy/errors/408.http
42         errorfile 500 /etc/haproxy/errors/500.http
43         errorfile 502 /etc/haproxy/errors/502.http
44         errorfile 503 /etc/haproxy/errors/503.http
45         errorfile 504 /etc/haproxy/errors/504.http
46  
47 listen stats
48         mode http
49         bind :9090
50         stats enable
51         stats hide-version
52  
53 stats uri       /haproxyadmin?stats
54         stats realm     Haproxy\ Statistics
55         stats auth      admin:admin
56  
57 frontend main
58 bind 0.0.0.0:80
59         default_backend         harbor
60  
61 backend harbor
62         balance leastconn
63         server harbor1 172.16.0.207:8888 check port 8888 maxconn 300
64         server harbor2 172.16.0.208:8888 check port 8888 maxconn 300

keeplived配置文件

root@k8s207:/opt/harbor# cat /etc/keepalived/keepalived.conf 
global_defs {
   smtp_connect_timeout 30 
   router_id keeplived_207
}
 
 
vrrp_instance VI_1 {
    state MASTER
    interface ens32 
    virtual_router_id 51 
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.0.10
    }
}

访问测试

 

 

 

 配置高可用

仓库管理 -> 添加目标

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2022-01-05 23:06  闫世成  阅读(236)  评论(0编辑  收藏  举报