This guide assumes Harbor Tanzu Package was installed by CLI & details how to:
• Uninstall the Harbor Tanzu package from the existing namespace where PVs exist
• Reinstall the Harbor Tanzu package using existing PVs in the new namespace
TKGs
TMC
Requirement to change the namespace name of the Harbor Tanzu package
Note: Backup the require Harbor data before performing the following actions to avoid data loss.
kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO Delete Bound harbor/data-harbor-redis-0 default 141m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 5Gi RWO Delete Bound harbor/data-harbor-trivy-0 default 141m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 10Gi RWO Delete Bound harbor/harbor-registry default 141m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO Delete Bound harbor/harbor-jobservice default 141m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO Delete Bound harbor/database-data-harbor-database-0 default 141m
kubectl get pv <pv-name> -o yaml
# The output:
apiVersion: v1
kind: PersistentVolume
metadata:
...
spec:
...
persistentVolumeReclaimPolicy: Delete
...
# If there are Harbor PVs only, run the following command to update the reclaim policy of all PVs at once
kubectl patch $(kubectl get pv -o name) -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
# Otherwise, patch the PVs one by one
kubectl patch pv <pv-name> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
kubectl -n <orignal-namespace> get pvc -l app=harbor -o yaml > pvcs.yaml
tanzu package installed delete <harbor-package-name> -n <original-namespace> -y
# If there are Harbor PVs only, run the following command to update the reclaim policy of all PVs at once
kubectl patch $(kubectl get pv -o name) -p '[{"op":"remove","path":"/spec/claimRef"}]' --type json
# Otherwise, patch the PVs one by one
kubectl patch pv <pv-name> -p '[{"op":"remove","path":"/spec/claimRef"}]' --type json
# Make sure PVs are in "Available" status
kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO Retain Available default 2d22h
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 5Gi RWO Retain Available default 2d22h
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 10Gi RWO Retain Available default 2d22h
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO Retain Available default 2d22h
pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO Retain Available default 2d22
# Create the new namespace if it doesn't exist
kubectl create ns <new-namespace>
# Edit the pvcs.yaml and update all "metadata.namespace" fields from <original-namespace> to <new-namespace>
vi pvcs.yaml
# Create the PVCs in the new namespace
kubectl apply -n <new-namespace> -f pvcs.yaml
# Make sure all PVCs are bound
kubectl -n harbor-dev get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
data-harbor-redis-0 Bound pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO default 14s
data-harbor-trivy-0 Bound pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 5Gi RWO default 14s
database-data-harbor-database-0 Bound pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO default 14s
harbor-jobservice Bound pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 1Gi RWO default 14s
harbor-registry Bound pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 10Gi RWO default 14s
...
other configurations
...
namespace: <new-namespace>
persistence:
persistentVolumeClaim:
trivy:
existingClaim: data-harbor-trivy-0
registry:
existingClaim: harbor-registry
redis:
existingClaim: data-harbor-redis-0
jobservice:
jobLog:
existingClaim: harbor-jobservice
database:
existingClaim: database-data-harbor-database-0
tanzu package install harbor -p harbor.tanzu.vmware.com --version <version> -n <new-namespace> --values-file harbor-values.yaml
Backup of data as advised above must be carried out before performing this procedure.
Harbor Read Only can be enabled/disabled as per link here.