harbor docker registry

Harbor 升級步驟:從 v1.10.1 升級至 v2.5.0

石偉琪 Vicky Shih 2022/07/14 12:47:20
280

1. Harbor 簡介

Harbor 就跟 Kubernetes 一樣,也是一個從 CNCF 畢業的 Open source 專案,目的是用來儲存與管理 container images

 

 

2. 升級目的說明

公司使用的 Harbor 原來的版本為 v1.10.1, 因該版本有 bug,而導致了設定的 GC 排程作業不會自動地觸發,故安排於離峰時段,將 harbor 的版本,升級至 v2.5.0

 

 

3. 原有環境

在進行正式的升級作業之前,我們先在測試環境下的 10.20.30.177 (caai5) 上,比照 production 環境安裝了 harbor,資訊如下:

 

  • docker version: 20.10.14(註1)
  • docker-compose version: 1.29.2
  • harbor version: 1.10.1
  • protocol: http

 

harbor 原始的版本資訊如下:

 

註1:

原來我們測試環境使用的 docker 版本為 19.03.5,但 harbor 升級至 v2.5.0 後,驗證測試的結果,會出現原有的 project / repositories 都會看不見。

後來把 docker 版本升到最新後,再重新進行升級的步驟,測試的結果才如預期目標。

 

 

4. 預期目標

升級的預期目標如下:

 

  • harbor 版本升級至 v2.5.0

 

 

  • 原有之 project / repositories 在升級之後,都要確認存在

 

 

為了做為之後驗證使用,事先於 10.20.30.177 的 harbor 上,建立了一個做為測試用的 project,名字是 test,並預先上傳兩個 image

 

 

5. 升級步驟

官方的升級文件 上看到,如果原來的版本是 v1.10 系列的話,就可以直接升到 v2 系列,也就是說,看起來應該要可以直接從 v1.10.1 --> v2.5.0 。

但實測發現,雖然軟體是升級成功了,但原來的 project 以及 image 都會消失,便與我們預期結果不同。

後來在網路上找到另一篇 參考文件 ,把步驟更正為 v1.10.1 --> v1.10.10 (v1.10 系列最後的版本) --> v2.5.0 就可以達到預期的結果了。

 

以下是升級步驟:

 

5.1  v1.10.1 --> v1.10.10

1. 停止 harbor : docker-compose down

[root@caai5 harbor]# pwd
/opt/harbor
[root@caai5 harbor]# docker-compose down Stopping nginx ... done Stopping harbor-jobservice ... done Stopping harbor-core ... done Stopping harbor-db ... done Stopping harbor-portal ... done Stopping registryctl ... done Stopping registry ... done Stopping redis ... done Stopping harbor-log ... done Removing nginx ... done Removing harbor-jobservice ... done Removing harbor-core ... done Removing harbor-db ... done Removing harbor-portal ... done Removing registryctl ... done Removing registry ... done Removing redis ... done Removing harbor-log ... done Removing network harbor_harbor

 

2. 備份 harbor.yaml 以及 database

直接把 harbor 那個目錄更名,把 data(預設路徑為 /data)copy 至另一個目錄下

[root@caai5 opt]# mv harbor harbor_v1.10.1
[root@caai5 opt]# cp -pr /data/database /harbor_backup/database_v1.10.1

 

3. 下載 upgrade tool

這裡要透過 harbor-migrator:v1.10.8-dev 這個 container image 來做 migrate

[root@caai5 opt]# docker pull goharbor/harbor-migrator:v1.10.8-dev
v1.10.8-dev: Pulling from goharbor/harbor-migrator
f206db2fdb4e: Pull complete
e2d65709eea4: Pull complete
c11b1fd21263: Pull complete
Digest: sha256:cef34cefc0eefff762bdc384ab0e43e9a434bc8507960a6652ae01728f99cf09
Status: Downloaded newer image for goharbor/harbor-migrator:v1.10.8-dev
docker.io/goharbor/harbor-migrator:v1.10.8-dev

 

4. 下載 harbor-offline-installer-v1.10.10.tar.gz,並將它解開

官方下載點: https://github.com/goharbor/harbor/releases/tag/v1.10.10

[root@caai5 src]# tar xfp harbor-offline-installer-v1.10.10.tgz -C /opt

 

5. 掛載 harbor v1.10.10 所有的 image

harbor-offline-installer-v1.10.10.tgz 解開後,會看到 harbor.v1.10.10.tar.gz 這個檔案

這個檔案就是該版本會用到所有的 images,直接執行 docker image load -i harbor.v1.10.10.tar.gz 掛載

[root@caai5 src]# cd /opt/harbor/
[root@caai5 harbor]# ls -al
total 598000
drwxr-xr-x  2 root root      4096 Apr 25 15:05 .
drwxr-xr-x. 9 root root      4096 Apr 25 15:05 ..
-rw-r--r--  1 root root     11347 Jan 12 12:08 LICENSE
-rw-r--r--  1 root root      3398 Jan 12 12:08 common.sh
-rw-r--r--  1 root root 612306524 Jan 12 12:09 harbor.v1.10.10.tar.gz
-rw-r--r--  1 root root      5882 Jan 12 12:08 harbor.yml
-rwxr-xr-x  1 root root      2284 Jan 12 12:08 install.sh
-rwxr-xr-x  1 root root      1750 Jan 12 12:08 prepare

[root@caai5 harbor]# docker image load -i harbor.v1.10.10.tar.gz
454bac8f976d: Loading layer [==================================================>]  34.62MB/34.62MB
babe85b686ad: Loading layer [==================================================>]   11.4MB/11.4MB
259a4c53fb16: Loading layer [==================================================>]  7.697MB/7.697MB
98ac3dea2937: Loading layer [==================================================>]  223.2kB/223.2kB
cdaa2acc770f: Loading layer [==================================================>]  195.1kB/195.1kB
0a48234d6364: Loading layer [==================================================>]  15.36kB/15.36kB
173c8c58ac9c: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-portal:v1.10.10
b380398fcbd9: Loading layer [==================================================>]  9.549MB/9.549MB
bc529c783a53: Loading layer [==================================================>]  3.584kB/3.584kB
e9ce0315169d: Loading layer [==================================================>]  3.072kB/3.072kB
67bd603fe25a: Loading layer [==================================================>]  18.95MB/18.95MB
14e24ca9b198: Loading layer [==================================================>]  19.78MB/19.78MB
Loaded image: goharbor/registry-photon:v1.10.10
6230e8094809: Loading layer [==================================================>]  9.549MB/9.549MB
0a9687793924: Loading layer [==================================================>]  12.09MB/12.09MB
82b02208b278: Loading layer [==================================================>]  12.09MB/12.09MB
Loaded image: goharbor/clair-adapter-photon:v1.10.10
facb3a7ee1e6: Loading layer [==================================================>]  9.549MB/9.549MB
81d29f7fac9d: Loading layer [==================================================>]  62.66MB/62.66MB
37883bc38d7c: Loading layer [==================================================>]  3.072kB/3.072kB
8aa48f380871: Loading layer [==================================================>]  3.584kB/3.584kB
c5681a8ef18a: Loading layer [==================================================>]  63.48MB/63.48MB
Loaded image: goharbor/chartmuseum-photon:v1.10.10
56bbc9cc94cf: Loading layer [==================================================>]  9.544MB/9.544MB
a207919569bf: Loading layer [==================================================>]  5.925MB/5.925MB
0a29582a26cd: Loading layer [==================================================>]  13.33MB/13.33MB
1b0a8ff5a816: Loading layer [==================================================>]  26.35MB/26.35MB
6dbcc574c94e: Loading layer [==================================================>]  22.02kB/22.02kB
f166ede0750a: Loading layer [==================================================>]  13.33MB/13.33MB
Loaded image: goharbor/notary-signer-photon:v1.10.10
86aaaa5372f8: Loading layer [==================================================>]  119.8MB/119.8MB
819275c346fd: Loading layer [==================================================>]  48.71MB/48.71MB
ea77710b7898: Loading layer [==================================================>]   2.56kB/2.56kB
ca2a3efc6750: Loading layer [==================================================>]  1.536kB/1.536kB
dfe233b9926d: Loading layer [==================================================>]  155.6kB/155.6kB
c3a75b2ecccd: Loading layer [==================================================>]  1.776MB/1.776MB
Loaded image: goharbor/prepare:v1.10.10
a4ba54e44ac3: Loading layer [==================================================>]  13.31MB/13.31MB
f1e6788f29b8: Loading layer [==================================================>]  35.84MB/35.84MB
e570535efa12: Loading layer [==================================================>]  5.632kB/5.632kB
cecb134ae993: Loading layer [==================================================>]  40.45kB/40.45kB
b1df430d541c: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v1.10.10
9d61b49d78e8: Loading layer [==================================================>]  9.549MB/9.549MB
27d61b3545b1: Loading layer [==================================================>]  3.584kB/3.584kB
a2244026b9bc: Loading layer [==================================================>]  18.95MB/18.95MB
03c5dc84f868: Loading layer [==================================================>]  3.072kB/3.072kB
9b69c5c3d773: Loading layer [==================================================>]  7.739MB/7.739MB
edbd121a3ef0: Loading layer [==================================================>]  27.51MB/27.51MB
Loaded image: goharbor/harbor-registryctl:v1.10.10
f11324788e5e: Loading layer [==================================================>]  116.1MB/116.1MB
9594b2b5491a: Loading layer [==================================================>]  3.072kB/3.072kB
51e6f741940c: Loading layer [==================================================>]   59.9kB/59.9kB
4885c950d461: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.10.10
1eacc09320d3: Loading layer [==================================================>]  75.89MB/75.89MB
a3e3ad0e02b9: Loading layer [==================================================>]  3.584kB/3.584kB
b372494191eb: Loading layer [==================================================>]  3.072kB/3.072kB
1aad5535a60c: Loading layer [==================================================>]   2.56kB/2.56kB
986f9c984b66: Loading layer [==================================================>]  3.072kB/3.072kB
c143cc1290af: Loading layer [==================================================>]  3.584kB/3.584kB
a31a89cc6444: Loading layer [==================================================>]  12.29kB/12.29kB
3e91299418d7: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-log:v1.10.10
784f32f21e7f: Loading layer [==================================================>]  65.05MB/65.05MB
53f565435ba3: Loading layer [==================================================>]  91.13MB/91.13MB
2f17e0297083: Loading layer [==================================================>]  5.632kB/5.632kB
43bb299bbeb4: Loading layer [==================================================>]   2.56kB/2.56kB
b3851907b9a7: Loading layer [==================================================>]   2.56kB/2.56kB
e20d492b0d2f: Loading layer [==================================================>]   2.56kB/2.56kB
8593e00e527b: Loading layer [==================================================>]   2.56kB/2.56kB
064073f4d6fa: Loading layer [==================================================>]  10.75kB/10.75kB
Loaded image: goharbor/harbor-db:v1.10.10
3d696a50ec47: Loading layer [==================================================>]  13.31MB/13.31MB
158c565cf55a: Loading layer [==================================================>]  43.21MB/43.21MB
Loaded image: goharbor/harbor-jobservice:v1.10.10
6a7bbce7dc58: Loading layer [==================================================>]  5.925MB/5.925MB
a3ff85fb97ac: Loading layer [==================================================>]  14.86MB/14.86MB
afa213836201: Loading layer [==================================================>]  26.35MB/26.35MB
6b644a4c4d8f: Loading layer [==================================================>]  22.02kB/22.02kB
2832a6621437: Loading layer [==================================================>]  14.86MB/14.86MB
Loaded image: goharbor/notary-server-photon:v1.10.10
883a6e0d9000: Loading layer [==================================================>]   11.4MB/11.4MB
Loaded image: goharbor/nginx-photon:v1.10.10
8d231d997136: Loading layer [==================================================>]  123.1MB/123.1MB
8598b2dba190: Loading layer [==================================================>]  11.97MB/11.97MB
ddbec80c9a88: Loading layer [==================================================>]  3.072kB/3.072kB
0a79796e5549: Loading layer [==================================================>]  49.15kB/49.15kB
63fb85041d48: Loading layer [==================================================>]  3.584kB/3.584kB
6eb19cef8f23: Loading layer [==================================================>]  12.84MB/12.84MB
Loaded image: goharbor/clair-photon:v1.10.10

 

6. restore and upgrade harbor.yaml

先把原來備份的 harbor.yaml restore 回 v1.10.10 的安裝路徑之下

然後再執行 docker run -it --rm -v /opt/harbor/harbor.yml:/harbor-migration/harbor-cfg/harbor.yml goharbor/harbor-migrator:v1.10.8-dev --cfg up 進行 harbor 升級 

[root@caai5 harbor]# pwd
/opt/harbor
[root@caai5 harbor]# cp -pr ../harbor_v1.10.1/harbor.yml .
cp: overwrite './harbor.yml'? y

[root@caai5 harbor]# docker run -it --rm -v /opt/harbor/harbor.yml:/harbor-migration/harbor-cfg/harbor.yml goharbor/harbor-migrator:v1.10.8-dev --cfg up
Please backup before upgrade,
Enter y to continue updating or n to abort: y
The path of the migrated harbor.cfg is not set, the input file will be overwritten.
Command for config file migration: python ./cfg/run.py --input /harbor-migration/harbor-cfg/harbor.yml
Version of input harbor.yml is identical to target 1.10.0, no need to upgrade

如上圖,如果新版的設定不需要更動 harbor.yaml,就會出現 no need to upgrade 的字眼

 

7. install and start harbor v1.10.10

透過 install.sh 進行安裝,之後它會自行將 harbor 以 docker-compose up -d 的方式啟動

[root@caai5 harbor]# pwd
/opt/harbor
[root@caai5 harbor]# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 20.10.14

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 1.29.2

[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-portal:v1.10.10
Loaded image: goharbor/registry-photon:v1.10.10
Loaded image: goharbor/clair-adapter-photon:v1.10.10
Loaded image: goharbor/chartmuseum-photon:v1.10.10
Loaded image: goharbor/notary-signer-photon:v1.10.10
Loaded image: goharbor/prepare:v1.10.10
Loaded image: goharbor/harbor-core:v1.10.10
Loaded image: goharbor/harbor-registryctl:v1.10.10
Loaded image: goharbor/redis-photon:v1.10.10
Loaded image: goharbor/harbor-log:v1.10.10
Loaded image: goharbor/harbor-db:v1.10.10
Loaded image: goharbor/harbor-jobservice:v1.10.10
Loaded image: goharbor/notary-server-photon:v1.10.10
Loaded image: goharbor/nginx-photon:v1.10.10
Loaded image: goharbor/clair-photon:v1.10.10


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
/usr/src/app/utils/configs.py:100: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  configs = yaml.load(f)
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
/usr/src/app/utils/configs.py:90: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  versions = yaml.load(f)
Clean up the input dir



[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-portal ... done
Creating registryctl   ... done
Creating harbor-db     ... done
Creating redis         ... done
Creating registry      ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----

 

8. 驗證 harbor v1.10.10 啟動後,可以看到 project 以及 repositories

版本資訊:看起來已經升級成 v1.10.10 了,底圖雖然不明顯,但可以看得出來是 test 這個 project,以及有兩個 image

驗證完畢後,就可以進行 5.2 的部份

 

5.2 v1.10.10 --> v2.5.0

從 v1.10.10 升級到 v2.5.0 的步驟,與 5.1 v1.10.1 --> v1.10.10 的步驟差不多

 

1. 停止 harbor v1.10.10:同樣是透過 docker-compose down

(在 harbor 停止後,我們有先將 docker 也停止,將 docker-ce 更新至 20.10.14,再進行 harbor 的升級)

[root@caai5 harbor]# docker-compose down
Stopping harbor-jobservice ... done
Stopping nginx             ... done
Stopping harbor-core       ... done
Stopping registry          ... done
Stopping redis             ... done
Stopping registryctl       ... done
Stopping harbor-portal     ... done
Stopping harbor-db         ... done
Stopping harbor-log        ... done
Removing harbor-jobservice ... done
Removing nginx             ... done
Removing harbor-core       ... done
Removing registry          ... done
Removing redis             ... done
Removing registryctl       ... done
Removing harbor-portal     ... done
Removing harbor-db         ... done
Removing harbor-log        ... done
Removing network harbor_harbor

 

2. 備份 v1.10.10 設定檔以及 database

與 5.1 v1.10.1 --> v1.10.10 的做法相同

[root@caai5 opt]# pwd
/opt
[root@caai5 opt]# mv harbor harbor_v1.10.10
[root@caai5 harbor_backup]# cp -pr /data/database /harbor_backup/database_v1.10.10

 

3. 下載 harbor-offline-installer-v2.5.0.tgz, 並解開至 /opt

官方下載點:https://github.com/goharbor/harbor/releases/tag/v2.5.0

[root@caai5 src]# tar xfp harbor-offline-installer-v2.5.0.tgz -C /opt 

 

4. 掛載 harbor v2.5.0 所有的 image ==> 會連同 upgrade 用到的 tool - prepare:v2.5.0 都一併掛載

harbor-offline-installer-v2.5.0.tgz 解開後,裡面會有一個檔案 harbor.v2.5.0.tar.gz

執行 docker image load -i harbor.v2.5.0.tar.gz 就會將所有的 image 掛載上來

[root@caai5 harbor]# docker image load -i harbor.v2.5.0.tar.gz
2728eced976d: Loading layer [==================================================>]  37.53MB/37.53MB
cc3b18252fc8: Loading layer [==================================================>]  8.682MB/8.682MB
e27442ada648: Loading layer [==================================================>]  3.584kB/3.584kB
510fffdc5915: Loading layer [==================================================>]   2.56kB/2.56kB
30467ddcf6f2: Loading layer [==================================================>]  78.68MB/78.68MB
7e04a5612589: Loading layer [==================================================>]  5.632kB/5.632kB
0ac0247e2d58: Loading layer [==================================================>]  99.84kB/99.84kB
420bc1ee1df5: Loading layer [==================================================>]  15.87kB/15.87kB
cc2bd615d6c2: Loading layer [==================================================>]  79.59MB/79.59MB
f10b6ae8e460: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.5.0
2c3687cd3c96: Loading layer [==================================================>]  8.682MB/8.682MB
ffaf1e983398: Loading layer [==================================================>]  3.584kB/3.584kB
6dca51eebde6: Loading layer [==================================================>]   2.56kB/2.56kB
e4bbd379d36f: Loading layer [==================================================>]  90.73MB/90.73MB
0c5623dfd7c8: Loading layer [==================================================>]  91.52MB/91.52MB
Loaded image: goharbor/harbor-jobservice:v2.5.0
6693dd6cc84d: Loading layer [==================================================>]  5.535MB/5.535MB
3a46d81a0f15: Loading layer [==================================================>]  8.543MB/8.543MB
1e10a48739ea: Loading layer [==================================================>]  14.47MB/14.47MB
b54aab661800: Loading layer [==================================================>]  29.29MB/29.29MB
8f500c8fb731: Loading layer [==================================================>]  22.02kB/22.02kB
15fdd079b41a: Loading layer [==================================================>]  14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.5.0
06b7933f92b4: Loading layer [==================================================>]  1.097MB/1.097MB
69fae5574072: Loading layer [==================================================>]  5.889MB/5.889MB
af3112c929b0: Loading layer [==================================================>]    168MB/168MB
03f5f7cbe3a7: Loading layer [==================================================>]  16.27MB/16.27MB
61c47e73996b: Loading layer [==================================================>]  4.096kB/4.096kB
ca3b66c3cab8: Loading layer [==================================================>]  6.144kB/6.144kB
94865dea6411: Loading layer [==================================================>]  3.072kB/3.072kB
2c98011427ba: Loading layer [==================================================>]  2.048kB/2.048kB
b497970298a9: Loading layer [==================================================>]   2.56kB/2.56kB
3b6f7dbc8aef: Loading layer [==================================================>]   2.56kB/2.56kB
2e79a86e0f4c: Loading layer [==================================================>]   2.56kB/2.56kB
9a01f04243a5: Loading layer [==================================================>]  8.704kB/8.704kB
Loaded image: goharbor/harbor-db:v2.5.0
826c5dd08e02: Loading layer [==================================================>]   5.54MB/5.54MB
7c9c7bdcf444: Loading layer [==================================================>]  4.096kB/4.096kB
f223cbf045aa: Loading layer [==================================================>]  17.32MB/17.32MB
38956705c7f1: Loading layer [==================================================>]  3.072kB/3.072kB
99a84179e4ff: Loading layer [==================================================>]  29.12MB/29.12MB
acbe177c3da5: Loading layer [==================================================>]  47.23MB/47.23MB
Loaded image: goharbor/harbor-registryctl:v2.5.0
a04b11a8a6ee: Loading layer [==================================================>]    122MB/122MB
5fd3685787a9: Loading layer [==================================================>]  3.072kB/3.072kB
4ee52d1501b6: Loading layer [==================================================>]   59.9kB/59.9kB
cfcae3e40a56: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.5.0
95de1218b455: Loading layer [==================================================>]  7.453MB/7.453MB
0332b27525fd: Loading layer [==================================================>]  7.362MB/7.362MB
2b702d470d2f: Loading layer [==================================================>]      1MB/1MB
Loaded image: goharbor/harbor-portal:v2.5.0
16ab1b0f6423: Loading layer [==================================================>]  6.067MB/6.067MB
71741b9e40d6: Loading layer [==================================================>]  4.096kB/4.096kB
b6227c4d071e: Loading layer [==================================================>]  3.072kB/3.072kB
ce0427bdf83d: Loading layer [==================================================>]  47.85MB/47.85MB
2e2a73e9bf05: Loading layer [==================================================>]  12.38MB/12.38MB
ec1590e149e7: Loading layer [==================================================>]  61.02MB/61.02MB
Loaded image: goharbor/trivy-adapter-photon:v2.5.0
c91db62634c3: Loading layer [==================================================>]  7.453MB/7.453MB
Loaded image: goharbor/nginx-photon:v2.5.0
d7cf625fc9a4: Loading layer [==================================================>]   5.54MB/5.54MB
b451f0ec0b7a: Loading layer [==================================================>]  4.096kB/4.096kB
b88e800d533f: Loading layer [==================================================>]  3.072kB/3.072kB
db6daabbcca3: Loading layer [==================================================>]  17.32MB/17.32MB
695d78a7189a: Loading layer [==================================================>]  18.12MB/18.12MB
Loaded image: goharbor/registry-photon:v2.5.0
89c925538f60: Loading layer [==================================================>]  5.535MB/5.535MB
e4324e4ca305: Loading layer [==================================================>]  8.543MB/8.543MB
81fb5fe866e7: Loading layer [==================================================>]  15.88MB/15.88MB
d7a351be6527: Loading layer [==================================================>]  29.29MB/29.29MB
1a27b90552b4: Loading layer [==================================================>]  22.02kB/22.02kB
9cbf49e39556: Loading layer [==================================================>]  15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.5.0
d157647932aa: Loading layer [==================================================>]  5.539MB/5.539MB
47c8814697b5: Loading layer [==================================================>]  90.86MB/90.86MB
101c95239656: Loading layer [==================================================>]  3.072kB/3.072kB
ab57dc233b33: Loading layer [==================================================>]  4.096kB/4.096kB
a5fa5daa44ac: Loading layer [==================================================>]  91.65MB/91.65MB
Loaded image: goharbor/chartmuseum-photon:v2.5.0
c7b58a7cc092: Loading layer [==================================================>]  167.8MB/167.8MB
b3dc882c87d2: Loading layer [==================================================>]  67.83MB/67.83MB
d84728b46c3d: Loading layer [==================================================>]   2.56kB/2.56kB
b2451fcf6b6e: Loading layer [==================================================>]  1.536kB/1.536kB
c0d555c98da7: Loading layer [==================================================>]  12.29kB/12.29kB
2bf34ea57de3: Loading layer [==================================================>]  2.621MB/2.621MB
77c438a147df: Loading layer [==================================================>]  354.8kB/354.8kB
Loaded image: goharbor/prepare:v2.5.0
79d6933e24a3: Loading layer [==================================================>]  126.1MB/126.1MB
3488b7bd8881: Loading layer [==================================================>]  3.584kB/3.584kB
7c322822684a: Loading layer [==================================================>]  3.072kB/3.072kB
3a1942a8665c: Loading layer [==================================================>]   2.56kB/2.56kB
68dc95a925af: Loading layer [==================================================>]  3.072kB/3.072kB
f5ad41459af9: Loading layer [==================================================>]  3.584kB/3.584kB
fcf472032de4: Loading layer [==================================================>]  20.99kB/20.99kB
Loaded image: goharbor/harbor-log:v2.5.0
c548f6088999: Loading layer [==================================================>]  8.682MB/8.682MB
cca18a30887f: Loading layer [==================================================>]  20.98MB/20.98MB
0625337d71b6: Loading layer [==================================================>]  4.608kB/4.608kB
65af3866d520: Loading layer [==================================================>]  21.77MB/21.77MB
Loaded image: goharbor/harbor-exporter:v2.5.0

 

5. restore harbor.yml

掛載好 image 後,要記得把 v1.10.10 的 harbor.yaml 這個設定檔,放到解開的目錄之下

[root@caai5 opt]# pwd
/opt
[root@caai5 opt]# cp -pr harbor_v1.10.10/harbor.yml harbor

 

6. upgrade harbor.yml

新版 v2.5.0 的設定會有一些不同,接下來要透過 prepare:v2.5.0 這個 tool 來更新 harbor.yaml 這個設定檔

[root@caai5 harbor]# docker run -it --rm -v /:/hostfs goharbor/prepare:v2.5.0 migrate -i /opt/harbor/harbor.yml
migrating to version 2.0.0
migrating to version 2.1.0
migrating to version 2.2.0
migrating to version 2.3.0
migrating to version 2.4.0
migrating to version 2.5.0
Written new values to /opt/harbor/harbor.yml

從 log 裡,可以看得出來是一個版本一個版本地升到 v2.5.0

(可以用 diff 比對原始的 harbor.yaml 以及更新後的 harbor.yaml,會發現有部份的設定有所不同)

 

7. install and start harbor v2.5.0

接下來就可以執行 install.sh 進行 harbor v2.5.0 的安裝

[root@caai5 harbor]# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 20.10.14

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 1.29.2

[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-core:v2.5.0
Loaded image: goharbor/harbor-jobservice:v2.5.0
Loaded image: goharbor/notary-signer-photon:v2.5.0
Loaded image: goharbor/harbor-db:v2.5.0
Loaded image: goharbor/harbor-registryctl:v2.5.0
Loaded image: goharbor/redis-photon:v2.5.0
Loaded image: goharbor/harbor-portal:v2.5.0
Loaded image: goharbor/trivy-adapter-photon:v2.5.0
Loaded image: goharbor/nginx-photon:v2.5.0
Loaded image: goharbor/registry-photon:v2.5.0
Loaded image: goharbor/notary-server-photon:v2.5.0
Loaded image: goharbor/chartmuseum-photon:v2.5.0
Loaded image: goharbor/prepare:v2.5.0
Loaded image: goharbor/harbor-log:v2.5.0
Loaded image: goharbor/harbor-exporter:v2.5.0


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir



[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-db     ... done
Creating registry      ... done
Creating harbor-portal ... done
Creating redis         ... done
Creating registryctl   ... done
Creating harbor-core   ... done
Creating harbor-jobservice ... done
Creating nginx             ... done
✔ ----Harbor has been installed and started successfully.----

安裝完成並成功啟動的話,會看到 Harbor has been installed and started successfully.

 

8. 驗證

實際 login harbor,除了可以看到已經升級至 v2.5.0 外,也確認可以看到 project 與 repositories

升級步驟至此已經成功完成

 

 

6. 結論

在本次的升級作業測試過程中,我們得到了以下的結論:

 

1. 就如同某些軟體的升級,總是要求要升級到某個版本的最新版本後,才能再往下一個版本升級

Harbor 大致是以 v1.10 為分界,在這之前,請按照 Harbor 的文件,先想辦法升級到 v1.10.10(即 Harbor v1.10 系列最後的版本),才後再升級至 v2.5.0(或更新)

 

2. harbor 本身是使用 docker-compose 來啟動一連串的服務,docker 以及 docker-compose 的版本,也需要注意與 harbor 匹配性問題

我們是因為在不同的環境上執行了相同的步驟,發現有些環境可以成功,有些環境卻會失敗。經比對了各環境的差異後,才發現 harbor 升級也需留意 docker 的版本

而這在官方的文件上沒有看到有載明

 

 

7. 參考文件

1. 官方文件:Upgrade to Harbor v1.10.0

https://goharbor.io/docs/1.10/administration/upgrade

 

2. 官方文件: Upgrade to Harbor v2.5.0

https://goharbor.io/docs/2.5.0/administration/upgrade/

 

3. harbor v1. Upgrade from 8.5 to v2.0 four point two

https://chowdera.com/2022/04/202204170633136256.html

石偉琪 Vicky Shih