安装 Harbor 私服
准备:安装docker和docker compose
http://t.csdn.cn/L3RLz
参考
https://blog.csdn.net/networken/article/details/107502461
- 下载 Harbor 文件
https://github.com/goharbor/harbor/releases - 解压harbor
tar zxf harbor-offline-installer-v2.5.3.tgz
- 修改配置文件
cp harbor.yml.tmpl harbor.yml
[外链图片转存中…(img-RNU4uWNt-1657624238329)]
- 生成私有配置
4.1 生成CA证书私钥
mkdir certs
openssl genrsa -out ca.key 4096
4.2 生成CA证书。
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=registry.harbor.com" \
-key ca.key \
-out ca.crt
4.3 生成服务器证书
openssl genrsa -out registry.harbor.com.key 4096
4.4 生成证书签名请求(CSR)
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=registry.harbor.com" \
-key registry.harbor.com.key \
-out registry.harbor.com.csr
4.5 生成一个x509 v3扩展文件
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=registry.harbor.com
DNS.2=registry.harbor
DNS.3=harbor
EOF
4.6 使用该v3.ext文件为您的Harbor主机生成证书
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in registry.harbor.com.csr \
-out registry.harbor.com.crt
4.7 提供证书给Harbor和Docker
mkdir -p /data/cert
cp registry.harbor.com.crt /data/cert/
cp registry.harbor.com.key /data/cert/
4.8 Docker守护程序将.crt文件解释为CA证书,并将.cert文件解释为客户端证书
openssl x509 -inform PEM -in registry.harbor.com.crt -out registry.harbor.com.cert
4.9 将服务器证书,密钥和CA文件复制到Harbor主机上的Docker证书文件夹中
mkdir -p /etc/docker/certs.d/registry.harbor.com/
cp registry.harbor.com.cert /etc/docker/certs.d/registry.harbor.com/
cp registry.harbor.com.key /etc/docker/certs.d/registry.harbor.com/
cp ca.crt /etc/docker/certs.d/registry.harbor.com/
4.10 执行harbor部署
./install.sh
4.11 修改host 文件
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 registry.harbor.com
4.12 访问地址
https://registry.harbor.com:8443/harbor/projects