部署harbor(centos-7)https连接方式
Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器
在网站设计制作、做网站中从网站色彩、结构布局、栏目设置、关键词群组等细微处着手,突出企业的产品/服务/品牌,帮助企业锁定精准用户,提高在线咨询和转化,使成都网站营销成为有效果、有回报的无锡营销推广。创新互联公司专业成都网站建设10年了,客户满意度97.8%,欢迎成都创新互联客户联系。
部署指南参考官网:https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
硬件要求:
Resource Capacity Description
CPU 2CPU 4CPU is preferred
Mem 4GB 8GB is preferred
Disk 40GB 160GB is preferred
软件要求
Software Version
Python version 2.7 or higher (自带)
Docker engine version 1.10 or higher
Docker Compose version 1.6.0 or higher
Openssl latest latest (自带)
1.安装docker “docker compose”
安装docker 参考我的另一篇文章(https://blog.51cto.com/9406836/2314122)
安装docker compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
2.下载harbor离线安装包
mkdir /harbor
cd /harbor
wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.5.4.tgz
tar xvf harbor-offline-installer-v1.5.4.tgz
cd harbor
3.生成利用openssl生成秘钥
3.1 生成自签证书,以及私钥。(这一步与下一步有重复,因为我又以CA的身份重新授权了一次)
mkdir /pri
cd /pri
openssl req -new -newkey rsa:2048 -nodes -keyout ca.key -x509 -days 365 -out ca.crt
/C=CN
/ST=GUANGDONG
/L=SZ
/O=example
/OU=Personal
/CN=yourdomain.com
# -newkey 生成私钥 -node 不加密 -keyout生成私钥 -x509证书结构文件 -out生成公钥 -days有效时间
3.2 编辑证书扩展文件v3.ext(主要目的是添加多域名认证,比如google.com证书下面,可以关联信任youku.com等证书)
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names] #重点在这,下面可以是你主机名,比如我的主机redhat.example.com
DNS.1=yourdomain.com
DNS.2=yourdomain
DNS.3=hostname
EOF
3.3 Harbor服务器(redhat.example.com为例,记得更改hosts)进行证书认证。
生成服务器私钥
openssl genrsa -out redhat.example.com.key 2048
生成认证请求(根据小道消息,CN信息一定要匹配服务器主机名)
openssl req -sha512 -new \
-subj "/C=CN/ST=GUANGDONG/L=SZ/O=XXX/OU=XXX/CN=redhat.example.com" \
-key redhat.example.com.key \
-out redhat.example.com.csr
3.4 CA服务器上进行认证授权(我是同一台)
cd /pri
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in redhat.example.com.csr \
-out redhat.example.com.crt
3.5 配置安装证书(harbor证书存放位置)
mkdir -p /data/cert
cp redhat.example.com.csr /data/cert/
cp redhat.example.com.crt /data/cert/
3.6 要为docker服务器安装证书,docker服务器要求证书要是.cert结尾的文件
openssl x509 -inform PEM -in example.com.crt -out example.com.cert
mkdir -p /etc/docker/certs.d/example.com
cp example.com.cert /etc/docker/certs.d/example.com/
cp example.com.key /etc/docker/certs.d/example.com/
cp ca.crt /etc/docker/certs.d/example.com/
部署后结构如下
/etc/docker/certs.d/
└── yourdomain.com:port
├── yourdomain.com.cert <-- Server certificate signed by CA
├── yourdomain.com.key <-- Server key signed by CA
└── ca.crt <-- Certificate authority that signed the registry certificate
4.部署harbor
4.1编辑配置文件
cd /harbor/harbor
vim harbor.cfg
#set hostname
hostname = redhat.example.com
#set ui_url_protocol
ui_url_protocol = https
......
#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /data/cert/redhat.example.com.crt
ssl_cert_key = /data/cert/redhat.example.com.key
4.2预编译文件
./prepare
4.3 安装harbor
./install.sh
4.4 启动harbor
docker-compose start
#4.5关闭harbor
docker-compose stop
5.web访问注册harbor
5.1登陆页面
https://redhat.example.com(记得添加hosts,记得添加证书信任)
5.2 注册账户
用户名:xxx 密码:xxx
6.客户端拉取镜像
6.1 首先将自签证书添加到信任列表
cp ca.crt /etc/pki/ca-trust/source/anchors/ca.crt
update-ca-certificates
6.2 重启docker
systemctl restart docker
6.3 连接登陆harbor
docker login redhat.example.com
用户名:xxx 密码:xxx
暂时就这么多,其实我想写很多我理解的细节,但是怕误人子弟,所以大家自己去查吧。
标题名称:部署harbor(centos-7)https连接方式
文章源于:http://myzitong.com/article/jjgsij.html