Harbor Migration Guide: From 2.6.4 to 2.12
TOC
Migration InstructionsMigrate Chart DataRequirementsMigrate Chart DataBackupMigrate DatabaseRequirementsRestore DatabaseDatabase MigrationStop the legacy Harbor instanceDeploy New Harbor InstanceGet Original Instance ConfigurationConvert Registry Storage ConfigurationConvert Access Method ConfigurationVerificationMigration Instructions
This guide describes how to upgrade Harbor from version 2.6.4 to version 2.12. Considering the large version gap and upgrade stability, we adopt a data migration approach for the upgrade. The advantages of this approach are:
- Avoiding the complexity of multiple intermediate version upgrades
- Reusing the registry storage data to speed up the upgrade process
The overall migration process is as follows:
- Migrate chart data to registry storage.
- Back up the PostgreSQL database and restore it to a PostgreSQL 14 instance.
- Stop the old Harbor instance.
- Deploy a new Harbor instance using the restored PostgreSQL database and the original registry storage from the old Harbor instance.
Migrate Chart Data
Harbor supports two different ways to store the Helms charts data: 1. stored in Harbor registry storage directly via OCI API. 2. stored in Harbor hosted chartmuseum backend via chartmuseum's API.
From Harbor 2.6, Chartmuseum is deprecated and is removed from Harbor 2.8. So if the old instance is using chartmuseum, you need to migrate the chart data to registry storage.
Requirements
podmaninstalled on your local machine.- Helm in version 3.8+.
Migrate Chart Data
The tool copies Helm charts but does not delete them from Chartmuseum.
Migrate the chart data to registry storage:
expected output:
If you only want to migrate a part of the data to registry storage, you can filter the data by project according to the documentation.
For information on how to use OCI Helm charts, please refer to the following documentation:
Since Harbor 2.8 no longer supports chartmuseum, we have decided to discontinue providing related support.
If you still want to use chart repositories managed by chartmuseum, please contact us for support.
The migration process primarily involves database backup and restoration, which means the migration time is directly proportional to the database size rather than the Registry storage space occupied by container images.
Based on testing with a 7.6GB database, the migration typically takes approximately 18 minutes (using storage with 6000 read IOPS and 2000 write IOPS performance).
Backup
Execute the following command to use pg_dump to backup the pg database of the old instance.
Registry data is typically very large, requiring additional storage for backup and taking a long time to complete, making it difficult to implement registry data backup. Additionally, Harbor instance upgrades usually do not change the registry storage structure, meaning it is feasible for the new instance to directly use the storage of the old instance.
Migrate Database
When migrating Harbor from 2.6 to 2.12, the database version also changes, upgrading from PostgreSQL 12 to PostgreSQL 14. Therefore, it is necessary to first import the database backup from the old instance into the new database (PostgreSQL 14). Then use the data migration tool provided by Harbor to migrate the database structure and data to the structure compatible with Harbor 2.12.
Requirements
Prepare a new PostgreSQL instance running version 14. The Harbor database backup will be restored to this instance, after which the database structure migration will be performed.
Restore Database
Import the backed up database into the database used by the new instance. The following example demonstrates the import process using psql. For specific import methods, please refer to the documentation provided by the database vendor.
Due to database version inconsistencies, the import process may show errors about non-existent roles or functions, which can be ignored. For example:
ERROR: role "admin" does not existERROR: function metric_helpers.pg_stat_statements(boolean) does not existERROR: schema "metric_helpers" already existsERROR: function "get_btree_bloat_approx" already exists with same argument types
Database Migration
The Harbor 2.6 data has now been imported into the new instance database. Next, run the data migration job to migrate the database structure and data to the structure compatible with Harbor 2.12.
Set the information for the new PostgreSQL instance, then create a job to execute the database migration:
Once the job has finished, you can view detailed migration progress and results in the job logs:
Stop the legacy Harbor instance
Uninstall the harbor operator from the Operator Hub page, then scale down the legacy Harbor instance by following commands:
Deploy New Harbor Instance
The new instance needs to mount the storage of the original instance, so it needs to be in the same namespace as the original instance.
Please deploy the new instance according to the deployment documentation, but pay attention to the following points:
- The new instance needs to connect to the migrated PG database (PostgreSQL 14)
- Do not reuse the Redis of the old Harbor instance, create a new one
- The registry storage needs to use the old instance's storage
- The access method needs to be consistent with the old instance to avoid affecting business usage after migration is completed
Please refer to the following sections for configuration migration between old and new instances.
Get Original Instance Configuration
We need to get the configuration from the original instance and convert it to the configuration of the new instance, as follows:
Convert Registry Storage Configuration
If the original instance is deployed with Host Path storage, the configuration is as follows:
Migrate to the new instance configuration:
If the original instance is deployed with a storage class, the PVC names are fixed:
- registry PVC name:
<old instance name>-harbor-registry
Use the old PVC in the new instance.
If the original instance is deployed with PVC, the configuration is as follows:
Convert Access Method Configuration
If the original instance is deployed with NodePort, set the following configuration:
If the original instance is deployed with a domain name, set the following configuration:
Verification
-
Check all Pod statuses:
-
Verify Harbor service is accessible:
- Access Harbor Web UI, verify existing projects and images are visible
- Test Podman login
-
Test pushing and pulling images/charts.
- Test pushing and pulling images
- Test pushing and pulling oci charts(optional)
-
After confirming the migration is successful, you can manually delete the old Harbor instance in
DevOps Toolchain/Instances/page.