Harbor 私有镜像仓库

  •  Harbor 简介
  • 使用 DNSMASQ 快速搭建简单 DNS 服务
  • 为 Harbor 签发域名证书
  • 信任自签发的域名证书
  • Harbor 1.8 版本配置与安装
  • 镜像管理与安全: 漏洞扫描和镜像签名
  • 镜像复制与同步
  • Harbor HA: 环境与准备
  • Harbor HA: 修改配置
  • Harbor HA: 启动 Harbor
  • Harbor HA: keepalived 安装配置与测试
  • OpenLDAP 安装与配置
  • OpenLDAP 创建组织架构与用户 和 Harbor 配置

 

 Harbor 简介


 

  • 简介
    • VMware 的开源项目 https://github.com/vmware/harbor
    • Harbor 可帮助用户迅速搭建企业级的 Registry 服务, 它提供了管理图形界面, 基于角色的访问控制 ( Role Based Access Control), 镜像远程复制 (同步), AD/LDAP 集成, 以及审计日志等企业用户需求的功能, 同时还原生支持中文, 深受中国用户的喜爱;
    • 该项目自退出以来, 在 GitHub 获得了超过 3300 多个 star 和 900 多个 forks (截至 2017-12-25)
  • 主要功能
    • 基于角色的访问控制: 用户与 Docker 镜像仓库通过 "项目" 进行组织管理, 一个用户可以对多个镜像仓库在同一命名空间(project)里有不同的权限
    • 图形化用户界面: 用户可以通过浏览器来浏览, 检索当前 Docker 镜像仓库, 管理项目和命名空间
    • 审计管理: 所有针对镜像仓库的操作都可以被记录追溯, 用于审计管理
    • 国际化: 基于英文与中文语言进行了本地化, 可以增加更多的语言信息
    • RESTful API: 提供给管理员对于 Harbor 更多的操控, 使得与其它管理软件集成变得更容易
    • LDAP 认证
    • 基于策略的 Docker 镜像复制功能, 可在不同的数据中心, 不同的运行环境之间同步镜像, 并提供友好的管理界面, 大大简化了实际运维中的镜像管理工作
    • 与 Clair 集成, 添加漏洞扫描功能(可以设置漏洞级别, 当漏洞级别达到一定程度时, 限制镜像的拉取) . Clair 是 coreos 开源的容器漏洞扫描工具, 在容器逐渐普及的几天, 容器镜像安全问题日益严重, Clair 是目前少数的开源安全扫描工具
    • Notary 是 Docker 镜像的签名工具, 用来保证镜像在 pull , push 和传输过程中的一致性和完整性, 避免中间人攻击, 避免非法的镜像更新和运行

 

使用 DNSMASQ 快速搭建简单 DNS 服务


 

  • 环境     DNS Server(DNS服务器)    /   Demo Server (测试DNS服务器);

                    CPU 1核↑                            CPU 1核↑

                    内存 512M↑                          内存 512M↑

                    磁盘 10G↑                            磁盘 10G↑

                    IP:192.168.9.28(自定义)         IP: 192.168.9.30(自定义)

 

  • 目标
    • 快速安装本地 DNS 服务器;
    • 使用 DNS 来自动设置主机名;

 

  • 步骤
    • 安装 dnsmasq
    • 修改配置
    • 启动 DNS 服务
    • 测试
// DNS 服务器安装 dnsmasq
[root@localhost ~]# yum -y install dnsmasq

// 修改配置文件, 添加一行指定文件(存放dns地址)位置
[root@localhost ~]# vim /etc/dnsmasq.conf 
... ...
110 #addn-hosts=/etc/banner_add_hosts
111 addn-hosts=/etc/domains
... ...

// 修改 /etc/domains 文件, 格式同 hosts 文件相同, IP 地址对应主机域名
[root@localhost ~]# vim /etc/domains
192.168.9.30    test-dns.mine.com

// 启动 dnsmasq 服务, 并设置开机启动
[root@localhost ~]# /etc/init.d/dnsmasq start
Starting dnsmasq:                                          [  OK  ]
[root@localhost ~]# chkconfig --level 35 dnsmasq on

// 修改测试机的 dns 
[root@tian ~]# vim /etc/resolv.conf 
nameserver 192.168.9.28

// 确定测试机可以ping 通, 及防火墙
[root@rong ~]# vim /etc/sysctl.conf net.ipv4.icmp_echo_ignore_all = 0
[root@rong ~]# sysctl -p
[root@rong ~]# echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all // 临时开启

[root@rong
~]# ping test-dns.mine.com PING test-dns.mine.com (192.168.9.30) 56(84) bytes of data. 64 bytes from test-dns.mine.com (192.168.9.30): icmp_seq=1 ttl=64 time=0.016 ms // 使用 dig 或者 nslookup 跟踪 test-dns.mine.com; dig中可看到 A 记录 test-dns.mine.com 解析192.168.9.30 [root@rong ~]# dig test-dns.mine.com ; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.1 <<>> test-dns.mine.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20131 ;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;test-dns.mine.com. IN A ;; ANSWER SECTION: test-dns.mine.com. 0 IN A 192.168.9.30 ;; Query time: 0 msec ;; SERVER: 192.168.9.28#53(192.168.9.28) ;; WHEN: Sun Jun 30 23:41:14 EDT 2019 ;; MSG SIZE rcvd: 51 [root@rong ~]# nslookup test-dns.mine.com Server: 192.168.9.28 Address: 192.168.9.28#53 Name: test-dns.mine.com Address: 192.168.9.30

 

为 Harbor 签发域名证书


 

// Linux中自己手动签发 ssl 证书
// 创建一个存放 证书 的目录
mkdir -p /data/ssl && cd /data/ssl

// 使用 RSA 方式加密, 生成 ca.key , 长度为 3072
[root@localhost ssl]# openssl genrsa -out ca.key 3072
Generating RSA private key, 3072 bit long modulus
...............................................................................++
.........................................................................................................................++
e is 65537 (0x10001)

// 通过 key 生成证书, 有效期为 1095 = 三年
[root@localhost ssl]# openssl req -new -x509 -days 1095 -key ca.key -out ca.pem
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN                 // 国家
State or Province Name (full name) []:BJ             // 州或者省名
Locality Name (eg, city) [Default City]:BJ           // 城市名称
Organization Name (eg, company) [Default Company Ltd]:zxjr      // 组织名称
Organizational Unit Name (eg, section) []:           // 组织单位名称(空)
Common Name (eg, your name or your server's hostname) []:       // 你的名称或服务器主机名
Email Address []:                                               // 邮箱

// 生成域名的证书
[root@localhost ssl]# openssl genrsa -out wap.zxjr.com.key 3072
Generating RSA private key, 3072 bit long modulus
........++
.......++
e is 65537 (0x10001)

// 生成证书请求,, 是后面签发证书时所需要的
[root@localhost ssl]# openssl req -new -key wap.zxjr.com.key -out wap.zxjr.com.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:zxjr
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:wap.zxjr.com              // 填写域名,
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

// 生成域名证书
[root@localhost ssl]# openssl x509 -req -in wap.zxjr.com.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out wap.zxjr.com.pem -days 1095
Signature ok
subject=/C=CN/ST=BJ/L=BJ/O=zxjr/CN=wap.zxjr.com
Getting CA Private Key

// 查看生成的证书
[root@localhost ssl]# ll
total 24
-rw-r--r-- 1 root root 2455 Jul  1 02:06 ca.key
-rw-r--r-- 1 root root 1533 Jul  1 02:09 ca.pem
-rw-r--r-- 1 root root   17 Jul  1 02:26 ca.srl
-rw-r--r-- 1 root root 1314 Jul  1 02:21 wap.zxjr.com.csr
-rw-r--r-- 1 root root 2455 Jul  1 02:15 wap.zxjr.com.key
-rw-r--r-- 1 root root 1448 Jul  1 02:26 wap.zxjr.com.pem

// 确认一下 wap.zxjr.com.pem 证书
[root@localhost ssl]# openssl x509 -noout -text -in wap.zxjr.com.pem
Certificate:
    Data:
        Version: 1 (0x0)
        Serial Number:
            c8:19:22:49:3d:f8:f1:b3
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=CN, ST=BJ, L=BJ, O=zxjr
        Validity           // 有效期从 2019年7月1号到 2022年6月30号.
            Not Before: Jul  1 06:26:03 2019 GMT
            Not After : Jun 30 06:26:03 2022 GMT
        Subject: C=CN, ST=BJ, L=BJ, O=zxjr, CN=wap.zxjr.com
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (3072 bit)
                Modulus:
                    00:ac:11:ce:8e:e6:f9:a4:18:2a:24:f2:e3:d8:af:
                    60:8d:8f:ef:b1:ef:47:de:07:29:7c:3e:cd:f1:b2:
                    80:1c:d6:11:2c:41:1d:35:13:9b:8a:8b:c6:9b:ac:
                    44:34:fa:fd:c0:24:f9:7f:b1:77:d7:bb:59:2b:99:
                    64:6a:25:8e:0f:77:f1:38:eb:bd:dc:da:a9:70:40:
                    bd:6a:ca:0e:bc:3d:0a:08:d2:77:55:fa:06:31:df:
                    eb:26:23:fe:fd:ba:5f:d2:4c:41:3f:f8:bd:b9:36:
                    ab:64:51:63:e4:5b:a8:ed:1c:da:8c:a6:6f:93:9b:
                    57:dd:fc:03:b5:62:67:ce:f5:a9:39:a3:da:0a:03:
                    7b:18:f7:95:aa:1b:f9:6e:80:88:f8:44:8b:58:91:
                    47:66:ff:a0:af:d7:b8:6d:d7:fa:23:e3:7a:54:4d:
                    61:2c:8c:26:5f:d4:d4:14:71:75:69:a7:68:f9:7b:
                    e8:08:96:6a:5c:6f:f2:8f:0f:b1:88:b2:fc:db:67:
                    2f:2f:c7:30:05:ba:ed:b0:a5:de:77:55:45:5d:7f:
                    36:b0:
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值