wyh-l6

导航

实战部署harbor并使用https访问(san签发证书)

#############################################部署harbor实现https访问,使用SAN签发证书
###################安装dockers-ce在线安装方式
##step 1: 安装必要的一些系统工具
# sudo apt-get update
# sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
##step 2: 安装GPG证书
# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
##Step 3: 写入软件源信息
# sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
##Step 4: 更新并安装Docker-CE
# sudo apt-get -y update
# sudo apt-get -y install docker-ce
##配置镜像加速器
# sudo mkdir -p /etc/docker
# sudo tee /etc/docker/daemon.json <<-'EOF'
{ "registry-mirrors": ["https://s3o5ymtt.mirror.aliyuncs.com"] }
EOF
# sudo systemctl daemon-reload && sudo systemctl restart docker
#######################源码安装方式
敬请期待----后续维护
#############################################################
##下载docker-compose
# wget https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64
# cp docker-compose-linux-x86_64 /usr/bin/docker-compose
# chmod +x /usr/bin/docker-compose
##安装harbor
# cd /usr/local/src/
##下载离线安装包
# wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz
# tar -zxvf harbor-offline-installer-v2.5.3.tgz
# cd harbor 
# cp harbor.yml.tmpl harbor.yml
##############################如果使用自签名证书启用https的做如下部分,否则跳过###################################
##创建证书存放目录
# mkdir /usr/local/src/harbor_ssl/ -p
# cd /usr/local/src/harbor_ssl/
##自定义域名并使用SAN签发证书,地址参考:https://goharbor.io/docs/2.4.0/install-config/configure-https/
# openssl genrsa -out ca.key 4096
# openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=jilin/L=changchun/O=example/OU=Personal/CN=harbor.wyh.net" \
-key ca.key \
-out ca.crt
# openssl genrsa -out harbor.wyh.net.key 4096
# openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=harbor.wyh.net" \
-key harbor.wyh.net.key \
-out harbor.wyh.net.csr
# cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=harbor.wyh.net
DNS.2=wyh.net
DNS.3=harbor.wyh.com
EOF
# openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in harbor.wyh.net.csr \
-out harbor.wyh.net.crt
########################################################################################################
# vim /usr/local/src/harbor/harbor.yml
    ##修改配置文件
    certificate::公钥路径
    private_key:私钥路径
    harbor_admin_password:管理端密码
    data_volume:镜像存储路径(存储空间一定要大)
##初始化harbor
##install参数说明
    --with-notary:开启后harbor必须使用https访问,并且你需要配置ui_url_protocol/ssl_cert/ssl_cert_key等参数
    --with-trivy:开启镜像扫描,扫面镜像有没有漏洞
    --with-chartmuseum:支持helm
####如果让客户端信任,客户端需要做如下操作###
##创建以harbor域名为命名的目录
# mkdir /etc/docker/certs.d/harbor.wyh.net -p
##将证书公钥远程cp到此目录下
# scp wyh@192.168.213.222:/usr/local/src/harbor_ssl/harbor.wyh.net.crt /etc/docker/certs.d/harbor.wyh.net/
##传好后可以测试推送image到harbor
#############################################部署harbor实现https访问,使用SAN签发证书大功告成!!!############

posted on 2022-07-22 09:04  IT老六  阅读(187)  评论(0编辑  收藏  举报