環(huán)境
部署測(cè)試時(shí)系統(tǒng): centos7.8
硬件
資源 | 容量 | 描述 |
---|---|---|
中央處理器 | 最小2 CPU | 4 CPU是首選 |
內(nèi)存 | 最小4GB | 8GB是首選 |
磁盤 | 最小40GB | 160GB是首選 |
2.1安裝步驟
配置自簽證書
cd /etc/ssl/certs/
mkdir domain.com
cd domain.com/
openssl genrsa -des3 -out server.key 2048 # 生產(chǎn)帶密碼的證書
openssl req -new -key server.key -out server.csr -subj "/C=CN/ST=Guangdong/L=Shenzhen/O=mw/OU=mw/CN=domain.com"
openssl rsa -in server.key -out server.key # 取消密碼
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
openssl dhparam -out dhparam.pem 2048
安裝harbor
wget https://github.com/goharbor/harbor/releases/download/v2.1.0/harbor-offline-installer-v2.1.0.tgz.asc
tar -xf harbor-offline-installer-v2.1.0.tgz -C /opt/
cp /opt/harbor/harbor.yml.tmpl /opt/harbor/harbor.yml
修改/opt/harbor/harbor.yml中的hostname字段為實(shí)際ip地址或者域名,域名ssl證書
bash /opt/harbor/install.sh --with-clair --with-chartmuseum
說明:
-
--with-notary
啟用harbor.yml中的https配置幔睬,加載證書嵌戈。 -
--with-clair
啟動(dòng)helm的clair格式 -
--with-chartmuseum
啟動(dòng)鏡像漏洞掃描
harbor.yml配置文件
只啟用http,前面有Nignx代理
5 hostname: domain.com #nginx 的主機(jī)名
10 port: 80 #改http端口
29 external_url: https://domain.com:443 #默認(rèn)沒啟用进陡,指定nginx代理上的訪問地址,必須寫端口號(hào)蕾殴,
34 harbor_admin_password: Harbor12345 #默認(rèn)admin登陸密碼
39 password: root123 #數(shù)據(jù)庫(kù)密碼,密碼不要帶?等特殊字符讯柔,否則導(dǎo)致clair組件連接不上數(shù)據(jù)庫(kù)
注釋掉13,15护昧,17魂迄,18行
13 #https:
15 # port: 443
17 # certificate: /your/certificate/path
18 # private_key: /your/private/key/path
項(xiàng)目配置文件修改
修改common/config/nginx/nginx.conf
sed -i 's/proxy_set_header\ X-Forwarded-Proto\ $scheme/#proxy_set_header X-Forwarded-Proto $scheme/' common/config/nginx/nginx.conf
前端nginx代理服務(wù)配置
server {
listen 443 ssl;
server_name hostname;
access_log /var/log/nginx/domain.com_nginx.log main;
include testsslset.conf;
location / {
client_max_body_size 1G;
proxy_pass http://10.10.2.14:81;
proxy_set_header X-Forwarded-Proto $scheme; #必須要的參數(shù),否則報(bào)401錯(cuò)誤
include proxy.conf;
}
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name hostname;
return 301 https://$server_name$request_uri;
}
啟用https時(shí)
在http的基礎(chǔ)上惋耙,開啟https選項(xiàng)捣炬,提供ssl證書
17,18c # https證書路徑
> certificate: /your/certificate/path
> private_key: /your/private/key/path
harbor服務(wù)管理
cd /opt/harbor/
啟動(dòng)harbor: `docker-compose up -d`
停止harbor: `docker-compose stop`
重啟harbor: `docker-compose restart`
查看harbor狀態(tài): `docker-compose ps`
查看harbor日志
harbor通過rsyslog收集日志,日志默認(rèn)在物理機(jī)的/var/log/harbor文件夾中
更新harbor.yml配置
- 編寫
harbor.yml
docker-compose down
- 把harbor.yml轉(zhuǎn)化為容器配置文件:
bash /opt/harbor/prepare --with-clair --with-chartmuseum
- 如果是http+nginx代理模式:
sed -i 's/proxy_set_header\ X-Forwarded-Proto\ $scheme/#proxy_set_header X-Forwarded-Proto $scheme/' common/config/nginx/nginx.conf
-
docker-compose up -d
注意:數(shù)據(jù)庫(kù)密碼在第一次初始化后绽榛,后面再修改配置的密碼湿酸,通過prepare更新配置后,會(huì)導(dǎo)致容器連接不上數(shù)據(jù)庫(kù)灭美,可通過install.sh重新安裝處理推溃,記得執(zhí)行前備份數(shù)據(jù)
。