Upgrade Harbor to MSR#
Overview#
Mirantis Secure Registry (MSR) is a Mirantis-maintained distribution of Harbor. MSR 4.13 and Harbor 2.13 use the same underlying database schema. As a result, the upgrade is a Helm chart replacement and does not require data migration or extended downtime.
Prerequisites#
- Current version: Harbor 2.13.x installed with Helm.
- Target version: MSR 4.13.x.
- Database: internal or external PostgreSQL.
- Cache: internal or external Redis or Valkey.
Before you begin#
Back up the Harbor database
-
Determine the PostgreSQL leader pod:
kubectl get pods -l application=spilo,spilo-role=master -
Back up the database for your deployment type:
kubectl exec -it <PostgreSQL leader pod> -- pg_dump -U msr \ registry > harbor-backup-$(date +%Y%m%d).sqlkubectl exec -it <PostgreSQL leader pod> -- pg_dump -U postgres \ registry > harbor-backup-$(date +%Y%m%d).sqlkubectl exec -it <PostgreSQL leader pod> -- pg_dump \ -U <PostgreSQL user> <PostgreSQL DB name> > \ harbor-backup-$(date +%Y%m%d).sql
Back up Harbor
See the Harbor documentation on backup and restore with Velero for information about backing up Harbor components other than the database.
Procedure#
-
Pull the default values file from the MSR Helm chart. The file lists the full set of configuration keys available for MSR, which differ slightly from the upstream Harbor chart.
helm show values oci://registry.mirantis.com/harbor/helm/msr \ --version 4.13.x > MSR4.13.x-values.yml -
Configure the
MSR4.13.x-values.ymlfile to match your current Harbor configuration. Compare your existing Harbor values against the MSR defaults, and carry over all site-specific settings manually.Verify the following fields:
Setting Location What to verify externalURLTop level Matches the current Harbor external URL exactly expose.typeexposeMatches the current expose type ( nodePort,ingress,clusterIP, orloadBalancer)expose.tlsexpose.tlsTLS enabled or disabled state, certSource, and secret names matchPersistent volume access modes persistence.persistentVolumeClaim.*Uses the same accessModeas the existing PVCs (for example,ReadWriteMany)Database connection databaseType (internal or external), host, port, username, password or secret, and SSL mode Redis connection redisType (internal or external), address, sentinel settings, and password or secret harborAdminPasswordTop level Matches the existing admin password or existing secret reference secretKeyTop level Identical to the existing 16-character key Image repositories Each component's image.repositoryUses the registry.mirantis.com/harbor/prefix instead ofgoharbor/Important
Do not change
secretKey. Harbor uses this key to encrypt sensitive data in the database. If the key changes, Harbor cannot decrypt stored credentials and secrets. -
Delete the existing Trivy StatefulSet before you run the Helm upgrade. The MSR chart changes the
volumeClaimTemplateslabels on the Trivy StatefulSet, and Kubernetes does not allow patching immutable fields on an existing StatefulSet.If you skip this step, the upgrade fails with the following error:
Error: UPGRADE FAILED: cannot patch "harbor-trivy" with kind StatefulSet: StatefulSet.apps "harbor-trivy" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'revisionHistoryLimit', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbiddenDelete the StatefulSet with the
--cascade=orphanflag. This flag removes the StatefulSet object from Kubernetes but leaves the Trivy pods running, which minimizes scanner downtime during the upgrade.kubectl delete statefulset harbor-trivy --cascade=orphan -
Run the Helm upgrade with your configured values file. Do not use
--reuse-values. Instead, pass your values explicitly with-fto avoid carrying over stale Harbor values that are incompatible with the MSR chart structure.helm upgrade harbor oci://registry.mirantis.com/harbor/helm/msr \ --version 4.13.x -f MSR4.13.x-values.ymlHelm pulls the MSR chart, applies your values, and rolls out updated pods for all Harbor components.