一、安裝docker
1.下載docker的rpm包
|
[root@harbor.yuanlinux.com ~] |
|
-rw-r--r-- 1 root root 101239922 Apr 12 15:29 docker-rpm-20_10_24.tar.gz |
2.解壓並安裝軟體包
|
[root@harbor.yuanlinux.com ~] |
|
[root@harbor.yuanlinux.com ~] |
|
[root@harbor.yuanlinux.com ~/docker-rpm-20.10] |
3.新增自動補全功能
|
[root@harbor.yuanliunx.com ~] |
|
[root@harbor.yuanliunx.com ~] |
4.配置映象加速
|
[root@harbor.yuanliunx.com ~/docker-rpm-20.10] |
|
[root@harbor.yuanliunx.com ~/docker-rpm-20.10] |
|
> { |
|
> "registry-mirrors": ["自己的加速地址"] |
|
> } |
|
> EOF |
|
[root@harbor.yuanliunx.com ~/docker-rpm-20.10] |
|
[root@harbor.yuanliunx.com ~/docker-rpm-20.10] |
|
|
5.驗證映象加速是否成功
|
[root@harbor.yuanliunx.com ~] |
|
WARNING: bridge-nf-call-iptables is disabled |
|
WARNING: bridge-nf-call-ip6tables is disabled |
|
Registry Mirrors: |
|
https://tuv7rqqq.mirror.aliyuncs.com/ |
6.將docker設定為開機自啟動
|
[root@harbor.yuanliunx.com ~] |
二、安裝docker compose
1.新增epel源
|
[root@harbor.yuanliunx.com ~] |
2.安裝docker-compose
|
[root@harbor.yuanliunx.com ~] |
3.檢視docker-compose版本
|
[root@harbor.yuanliunx.com ~] |
|
docker-compose version 1.18.0, build 8dd22a9 |
|
docker-py version: 2.6.1 |
|
CPython version: 3.6.8 |
|
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017 |
三、安裝harbor
1.下載harbor軟體包
|
[root@harbor.yuanlinux.com ~] |
|
-rw-r--r-- 1 root root 610192663 Apr 12 09:23 harbor-offline-installer-v1.10.10.tgz |
2.建立工作目錄
|
[root@harbor.yuanlinux.com ~] |
3.解壓harbor軟體包
|
[root@harbor.yuanlinux.com ~] |
4.建立證書的工作目錄
|
[root@harbor.yuanlinux.com ~] |
5.生成自建CA證書
5.1 進入證書目錄
|
[root@harbor.yuanlinux.com ~] |
5.2 生成CA私鑰
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
5.3 生成ca的自簽名證書
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
> -subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=yuanlinux.com" \ |
|
> -key ca/ca.key \ |
|
> -out ca/ca.crt |
6.生成harbor伺服器的證書檔案及客戶端證書
6.1 生成harbor主機的私鑰
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
Generating RSA private key, 4096 bit long modulus |
6.2 生成harbor主機的證書申請
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=harbor.yuanlinux.com" \ |
|
-key server/harbor.yuanlinux.com.key \ |
|
-out server/harbor.yuanlinux.com.csr |
6.3 生成x509 v3擴充套件檔案
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
authorityKeyIdentifier=keyid,issuer |
|
basicConstraints=CA:FALSE |
|
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment |
|
extendedKeyUsage = serverAuth |
|
subjectAltName = @alt_names |
|
|
|
[alt_names] |
|
DNS.1=yuanlinux.com |
|
DNS.2=yuanlinux |
|
DNS.3=harbor.yuanlinux.com |
|
EOF |
6.4 使用"v3.ext"給harbor主機簽發證書
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
-extfile v3.ext \ |
|
-CA ca/ca.crt -CAkey ca/ca.key -CAcreateserial \ |
|
-in server/harbor.yuanlinux.com.csr \ |
|
-out server/harbor.yuanlinux.com.crt |
6.5 將crt檔案轉換為cert客戶端證書檔案
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
6.6 準備docker客戶端證書
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
[root@harbor.yuanlinux.cn /data/softwares/harbor/certs] |
|
[root@harbor.yuanlinux.cn /data/softwares/harbor/certs] |
|
total 12 |
|
-rw-r--r-- 1 root root 2029 Apr 12 20:21 ca.crt |
|
-rw-r--r-- 1 root root 2118 Apr 12 20:21 harbor.yuanlinux.com.cert |
|
-rw-r--r-- 1 root root 3243 Apr 12 20:21 harbor.yuanlinux.com.key |
6.7 檢視所有證書檔案結果
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
.: |
|
total 4 |
|
drwxr-xr-x 2 root root 48 Apr 12 20:20 ca |
|
drwxr-xr-x 2 root root 83 Apr 12 20:21 client |
|
drwxr-xr-x 2 root root 131 Apr 12 20:21 server |
|
-rw-r--r-- 1 root root 272 Apr 12 20:19 v3.ext |
|
|
|
./ca: |
|
total 12 |
|
-rw-r--r-- 1 root root 2029 Apr 12 20:18 ca.crt |
|
-rw-r--r-- 1 root root 3243 Apr 12 20:16 ca.key |
|
-rw-r--r-- 1 root root 17 Apr 12 20:20 ca.srl |
|
|
|
./client: |
|
total 12 |
|
-rw-r--r-- 1 root root 2029 Apr 12 20:21 ca.crt |
|
-rw-r--r-- 1 root root 2118 Apr 12 20:21 harbor.yuanlinux.com.cert |
|
-rw-r--r-- 1 root root 3243 Apr 12 20:21 harbor.yuanlinux.com.key |
|
|
|
./server: |
|
total 16 |
|
-rw-r--r-- 1 root root 2118 Apr 12 20:21 harbor.yuanlinux.com.cert |
|
-rw-r--r-- 1 root root 2118 Apr 12 20:20 harbor.yuanlinux.com.crt |
|
-rw-r--r-- 1 root root 1716 Apr 12 20:19 harbor.yuanlinux.com.csr |
|
-rw-r--r-- 1 root root 3243 Apr 12 20:18 harbor.yuanlinux.com.key |
7.配置harbor伺服器使用證書
7.1 切換工作目錄
|
[root@harbor.yuanlinux.com /data/softwares/harbor/certs] |
|
[root@harbor.yuanlinux.com /data/softwares/harbor] |
7.2 修改配置檔案
|
[root@harbor.yuanlinux.com /data/softwares/harbor] |
|
|
|
5 hostname: harbor.yuanlinux.com |
|
17 certificate: /data/softwares/harbor/certs/server/harbor.yuanlinux.com.crt |
|
18 private_key: /data/softwares/harbor/certs/server/harbor.yuanlinux.com.key |
|
27 harbor_admin_password: 1 |
8. 安裝harbor服務
|
[root@harbor.yuanlinux.com /data/softwares/harbor] |
9.驗證
9.1 Windows驗證harbor的https
|
|
|
10.0.0.250 harbor.yuanlinux.com |
https://harbor.yuanlinux.com/
9.2 Linux驗證harbor的https
9.2.1 配置地址解析
|
[root@harbor.yuanlinux.com ~] |
9.2.2 在docker客戶端節點建立自簽證書域名存放路徑
|
[root@harbor.yuanlinux.com ~] |
9.2.3 服務端將證書檔案複製到客戶端docker節點,若不執行該操作,則會報錯"x509: certificate signed by unknown authority"
|
[root@harbor.yuanlinux.com ~] |
|
[root@harbor.yuanlinux.com ~] |
|
total 12 |
|
-rw-r--r-- 1 root root 2029 Apr 12 20:35 ca.crt |
|
-rw-r--r-- 1 root root 2118 Apr 12 20:35 harbor.linuxyuan.com.cert |
|
-rw-r--r-- 1 root root 3243 Apr 12 20:35 harbor.linuxyuan.com.key |
9.2.4 登入驗證
|
[root@harbor.yuanliunx.com /data/softwares/harbor] |
|
WARNING! Using --password via the CLI is insecure. Use --password-stdin. |
|
WARNING! Your password will be stored unencrypted in /root/.docker/config.json. |
|
Configure a credential helper to remove this warning. See |
|
https://docs.docker.com/engine/reference/commandline/login/ |
|
|
|
Login Succeeded |
9.2.5退出登入
|
[root@harbor.yuanlinux.com ~] |
|
{ |
|
"auths": { |
|
"harbor.yuanlinux.com": { |
|
"auth": "YWRtaW46MQ==" |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
[root@harbor.yuanlinux.com ~] |
|
Removing login credentials for harbor.yuanlinux.com |
|
|
|
[root@harbor.yuanlinux.com ~] |
|
{ |
|
"auths": {} |
|
} |
|
|
|
echo YWRtaW46MQ== | base64 -d | more |
補充
|
harbor有時重啟機器會有服務起不來,要檢視一下 |
|
|
|
[root@harbor.yuanliunx.com /data/softwares/harbor] |
|
|
|
[root@harbor.yuanliunx.com /data/softwares/harbor] |
|
[root@harbor.yuanliunx.com /data/softwares/harbor] |