So, lets say you want to deploy an instance of Harbor to your “services” kubernetes cluster. The cluster is protected by a scheduled Velero backup Velero pickup all resources in all namespaces by default, but we need to add an annotation to indicate a persistent volume that should be included in the backup. Without this annotation, Velero will not include the PV in the backup.
First, let’s create a namespace we want to install Harbor to:
kubectl create ns harbor
Then, we’ll make sure helm has the chart for Harbor
helm repo add harbor https://helm.goharbor.io
helm repo update
Finally, we’ll install harbor
helm install harbor harbor/harbor --namespace harbor \
Notice a few of the configurations we’re passing here:
- expose.tls.commonName is the value that will be used by the gnerated TLS certificate
- externalURL is the FQDN that we’ll use to reach Harbor (post deploy, you’ll get the loadBalancer IP and add the DNS record for it)
- harborAdminPassword is the password assigned by default to the admin account – clearly this should be changed immediately
- The next items are for the podAnnotations; the syntax was unexpectedly different. Notice there’s a dot instead of an equals-sign between the key and the value. Also notice that the dots in the value must be escaped.
Once Harbor is deployed, you can get the loadBalancer’s IP and point your browser at it.
Now, we can wait for the Velero backup job to run or kick off a one-off backup.
I noticed that Harbor did not start properly after restore. This was because postgres in the database pod expects a specific set of permissions – which were apparently different as a result of the restore. The log on the database pod only read FATAL: data directory “/var/lib/postgresql/data” has group or world access
To return Harbor to functionality post-restore, I had to take the following steps:
- Edit the database statefulSet:
kubectl edit StatefulSet harbor-harbor-database -n harbor
- Replace the command in the “change-permission-of-directory” initContainer from chown -R 999:999 /var/lib/postgresql/data to chmod -R 0700 /var/lib/postgresql/data
- Save changes and bounce the database pod by running
kubectl delete po -n harbor harbor-harbor-database-0
- Bounce the remaining pods that are in CrashLoopBackup (because they’re trying to connect to the database)
Thanks to my friend and colleague Hemanth AVS for help with the podAnnotations syntax!