How to upgrade Mirror H2 database inside Bitbucket Kubernetes pod
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
要約
There are manual tasks needed to upgrade Bitbucket Mirror or Bitbucket Mesh due to the H2 database usage. On bare-metal or physical servers, you can follow the steps in the Migrate H2 database guide. However, with Bitbucket Mirror installations using Kubernetes, we will need to orchestrate the steps as explained in this article.
- The H2 database is only used for Bitbucket Mirror and Bitbucket Mesh.
- This is not an as-is steps article - you might not be able to run the same exact commands and achieve the same result.
- The content in this article is to showcase a concept and should be adapted into the upgrade process for Bitbucket Mirror.
環境
- Please refer to the Migrate H2 database guide for the exact steps to be orchestrated.
- For this article, we are performing Bitbucket Mirror upgrade from 7.21.23 to 8.9.11.
Kubernetes Environment
These are assumptions, you will need to tweak the commands in this article to match your environment.
- Kubernetes namespace:
bitbucket-mirror
- helm chart name:
bitbucket-mirror
- helm values file:
values-bitbucket-mirror.yaml
- Bitbucket Home is stored in a Kubernetes PVC (persistent volume claim)
ソリューション
- Make sure you have all the required backups before performing any changes.
- Test the steps in a non-production environment.
Step 1: Bring down Bitbucket Mirror pod
Update the helm values:
replicaCount: 0
Bring down the pod:
helm upgrade --install bitbucket-mirror atlassian-data-center/bitbucket --namespace bitbucket-mirror --values values-bitbucket-mirror.yaml
Step 2: Deploy the H2 upgrade pod
Locate the Bitbucket Mirror PVC:
kubectl get pvc --namespace bitbucket-mirror
結果の例:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE local-home-bitbucket-mirror-0 Bound pvc-b9912c76-b2ab-4db5-8374-32c4e1aec2de 1Gi RWO hostpath 4h37m
Set up a new YAML file called
values-bitbucket-mirror-h2-upgrade.yaml
:apiVersion: v1 kind: Pod metadata: namespace: bitbucket-mirror name: bitbucket-mirror-h2-upgrade spec: restartPolicy: Never containers: - image: atlassian/bitbucket:8.9.11 name: bitbucket-mirror-h2-upgrade command: ["tail"] args: ["-f", "/dev/null"] volumeMounts: - mountPath: /pvc name: pvc-mount volumes: - name: pvc-mount persistentVolumeClaim: claimName: local-home-bitbucket-mirror-0
Deploy the H2 upgrade pod:
kubectl create -f values-bitbucket-mirror-h2-upgrade.yaml
Step 3: Perform the H2 upgrade
Log in to the H2 upgrade pod:
kubectl exec -it pod/bitbucket-mirror-h2-upgrade --namespace bitbucket-mirror -- /bin/bash
Obtain the H2 JAR file from the previous installation:
wget https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-7.21.23.tar.gz
tar -xvf \ atlassian-bitbucket-7.21.23.tar.gz \ --wildcards \ --strip-components=4 \ '*/app/WEB-INF/lib/h2-*.jar'
Run the upgrade script:
cd /opt/atlassian/bitbucket/bin
BITBUCKET_HOME=/pvc SOURCE_INST_DIR=/opt/atlassian/bitbucket SOURCE_H2_JAR_PATH=/h2-1.3.176.jar ./h2-migrate-db-file.sh
chown bitbucket:bitbucket /pvc/shared/data/*.db
Step 4: Tear down the H2 upgrade pod
Once we have a successful H2 upgrade, we can tear down the H2 upgrade pod:
kubectl delete -f values-bitbucket-mirror-h2-upgrade.yaml
Step 5: Upgrade the Bitbucket Mirror
Update the Bitbucket Mirror YAML file:
replicaCount: 1 image: tag: "8.9.11"
Bring up the Bitbucket Mirror and perform the upgrade:
helm upgrade --install bitbucket-mirror atlassian-data-center/bitbucket --namespace bitbucket-mirror --values values-bitbucket-mirror.yaml