Upgrade GitLab to 16.x (helm chart to 7.x)
gitlab.softwareheritage.org is currently running GitLab 15.11.x (chart 6.11.x), GitLab is now at 16.1.1 (chart 7.1.1, two monthly releases further).
The upgrade to GitLab 16.x comes with an upgrade of the following components:
Both of these upgrades need the frontend components to be completely shut down, and the postgresql upgrade needs a dump/restore, so some downtime (around 1h) needs to be planned.
The upgrade procedure, which was tested on the staging instance (freshly reset to a backup of the production instance), looks like the following:
- upgrade GitLab operator to latest version (in k8s-clusters-config)
- upgrade GitLab to latest available 15.11.x (in k8s-private-data)
- retrieve PostgreSQL database upgrade script locally
- disable self-healing of GitLab-related resources in argocd (k8s-clusters-config)
-
update the GitLab custom resource with the latest available 7.0.x chart version and migrations disabled. immediately scale down operator deployment to avoid applying the new template
kubectl edit gitlab gitlab && kubectl scale deployment --replicas 0 --selector 'control-plane=controller-manager'
- --- BEGIN long downtime
-
scale down front-end service deployments to avoid changes during database upgrade
kubectl scale deployment --replicas 0 --selector 'app in (webservice, sidekiq, kas, gitlab-exporter)'
-
database upgrade steps: dump database using the pre-upgrade script
./database-upgrade pre
-
database upgrade steps: drop the postgresql pvc and statefulset
kubectl delete statefulset gitlab-postgresql && kubectl delete pvc data-gitlab-postgresql-0
-
redis chart upgrade steps: drop the redis statefulset
kubectl delete statefulset gitlab-redis-master
-
scale up operator deployment. this will apply the chart upgrade to 7.0.x
kubectl scale deployment --replicas 1 --selector 'control-plane=controller-manager'
-
when toolbox container is ready, scale down operator deployment again (to avoid reconciles while the db upgrade script is running)
- wait for toolbox to be deployed with the new chart version:
while ! test $(kubectl get deployment/gitlab-toolbox -o 'jsonpath={.spec.template.metadata.labels.chart}) = 'toolbox-7.0.x'; do sleep 10; done; kubectl rollout status -w deployment/gitlab-toolbox; kubectl scale deployment --replicas 0 --selector 'control-plane=controller-manager'
- wait for toolbox to be deployed with the new chart version:
-
database upgrade steps: run post upgrade script
./database-upgrade post
-
scale operator deployment back up, wait for GitLab 16.0.x to finish reconciling
kubectl scale deployment --replicas 1 --selector 'control-plane=controller-manager' && kubectl wait --for condition=Available=true gitlab/gitlab
- --- END long downtime, GitLab is at 16.0.x
- restore self-healing of GitLab-related resources in ArgoCD
- update GitLab custom resource to chart 7.1.x, with migrations enabled
- wait for operator to reconcile GitLab 16.1.x