Upgrade harbor 1.10.5 to 2.1.1

2.1.1 Component version

Postgresql 9.6.10-1.ph2
Redis 4.0.10-1.ph2
Clair 2.0.8
Beego 1.9.0
Chart Museum 0.9.0
Docker/distribution 2.7.1
Docker/notary 0.6.1
Helm 2.9.1
Swagger-ui 3.22.1
Component Version

Only need to change the configuration file, the data content will be automatically updated after the harbor starts

Stop container

cd harbor
docker-compose down

Backup harbor and data

mv harbor /my_backup_dir/harbor
cp -r /data/database /my_backup_dir/

Convert harbor.yml

The configuration file harbor.yml of version 1.10 is converted to the configuration file harbor.yml of version 2.0

The upgrade and database migration of the database are performed when the harbor is started. If the migration fails, check core.log

# 拉取goharbor/prepare:v2.1.1镜像 
docker pull goharbor/prepare:v2.1.1
# 这里先拷贝一份原来的配置文件到一个目录下,这里我的是/data/harbor/harbor.yml 
# 不指定输出文件的话,默认到当前目录下,如果输入文件与输出文件在同一个目录,那么新版本的配置文件将会覆盖旧版本的配置文件,一定要做好备份 
docker run -it --rm -v /:/hostfs goharbor/prepare:v2.1.1 migrate -i /data/harbor/harbor.yml 

# 也可以写成
docker run -it --rm -v /:/hostfs goharbor/prepare:v2.1.1 migrate -i /data/harbor/harbor.yml -o /data/harbor/harbor_v2.yml -t 2.1.1

Pull the goharbor/prepare:v2.1.1 image. This image has 3 functions: prepare, gencert, and migrate , among which migrate is to convert the configuration file;

Migrate has three parameters :

  • -i: specify the configuration file to be converted, here is harbor.yml of version 1.10
  • -o: Which file to convert to, the default is harbor.yml in the current directory
  • -t: Convert to that version, here my prepare image is version 2.1.1, so the default is to convert the configuration file to version 2.0 format

Download the Harbor offline package version 2.1

wget https://github.com/goharbor/harbor/releases/download/v2.1.1/harbor-offline-installer-v2.1.1.tgz
tar -xvf harbor-offline-installer-v2.1.1.tgz
mv harbor /data/

Start harbor

Copy the converted configuration file to the harbor package of version 2.0 and start

./install.sh 

Mount the registry back

If there is a registry directory in the new version, an error will be reported and you need to remove it first. Wait for the harbor upgrade to complete and remount it back

docker-compose stop
rm -rf registry
ln -s /my_backup_dir/regisry .
docker-compose start

Guess you like

Origin blog.51cto.com/foxhound/2545082