Deployed to Kubernetes Cluster
Procedure outlined here is only applicable for upgrading to latest version
Use this procedure if you are deploying OneDev into Kubernetes. Below procedure assumes that you've added OneDev chart repository via below command:
helm repo add onedev https://dl.cloudsmith.io/public/onedev/onedev/helm/charts
Upgrade from Chart v >= 9.0.0
If you want to upgrade the chart version together with image version:
helm repo update onedev
helm upgrade onedev onedev/onedev -n onedev
If you only want to upgrade the image version:
helm upgrade onedev onedev/onedev -n onedev --set image.tag=<OneDev version>
Upgrade from Chart v >= 8.6.13 and v < 9.0.0
Since 9.0.0 OneDev runs as statefulset instead of deployment. This procedure migrates persistent volume storing OneDev data so that it can be used by statefulset.
Make sure to backup the persistent volume first before running below procedure
Identify name and capacity of the persistent volume storing OneDev data. We will refer to them as
<pv name>
and<pv capacity>
laterkubectl get pvc onedev -n onedev -o go-template='{{.spec.volumeName}} {{.status.capacity.storage}}'
Uninstall OneDev:
helm uninstall onedev -n onedev
Change persistentVolumeReclaimPolicy of the persistent volume to Retain:
kubectl patch pv <pv name> -p'{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}' -n onedev
Delete persistent volume claim onedev:
kubectl delete pvc onedev -n onedev
Patch the persistent volume to remove claimRef to make it available:
kubectl patch pv <pv name> -p'{"spec":{"claimRef":null}}' -n onedev
Create file sts-pvc.yaml with below content:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-onedev-0
spec:
accessModes:
- ReadWriteOnce
volumeName: <pv name>
resources:
requests:
storage: <pv capacity>Create the satefulset pvc using above file:
kubectl apply -f /path/to/sts-pvc.yaml -n onedev
Change persistentVolumeReclaimPolicy of the persistent volume back to Delete:
kubectl patch pv <pv name> -p'{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}' -n onedev
Now lets configure the paramaters for our new installation. Download file values.yaml, make necessary changes for your site, and run below commands to install latest version:
helm repo update onedev
helm install onedev onedev/onedev -n onedev -f /path/to/values.yaml
Upgrade from Chart v >= 8.5.0 and v < 8.6.13
Make sure to upgrade to 8.6.13 first with below commands:
helm repo update onedev
helm upgrade onedev onedev/onedev -n onedev --version 8.6.13 --set onedev.updateStrategy.type=Recreate --reuse-valuesFollow this procedure to upgrade 8.6.13 to latest version
Upgrade from Chart v <= 8.4.2
Since 8.5.0, OneDev pod no longer ships with MySQL database. This procedure migrates database to be managed by an external MySQL pod.
First, let's identify the names of the PVCs (Persistent Volume Claims) that were automatically created during the deployment. These PVCs are not removed when performing a helm uninstall, allowing us to preserve the data. The names are as follows:
- onedev-mysql (for MySQL)
- onedev (OneDev Data)
You can also retrieve this information directly from the cluster by running the following command:
kubectl get pvc -n onedev
Secondonly the password you setup for MySQL during install , you can also get this from cluster if you have changed it.
kubectl get secret -n onedev onedev-mysql -o go-template='{{.data.password | base64decode}}'
Here is a sample manifest used with the chart to deploy MySQL, Copy & save this to a file called mysql.yaml
apiVersion: v1
kind: Secret
metadata:
name: onedev-mysql
stringData:
password: changeit # change this if your password is different
---
apiVersion: v1
kind: Service
metadata:
name: onedev-mysql
labels:
app.kubernetes.io/name: mysql
app.kubernetes.io/instance: mysql
spec:
ports:
- port: 3306
selector:
app.kubernetes.io/name: mysql
app.kubernetes.io/instance: mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: onedev-mysql
labels:
app.kubernetes.io/name: mysql
app.kubernetes.io/instance: mysql
spec:
selector:
matchLabels:
app.kubernetes.io/name: mysql
app.kubernetes.io/instance: mysql
strategy:
type: Recreate
template:
metadata:
name: onedev-mysql
labels:
app.kubernetes.io/name: mysql
app.kubernetes.io/instance: mysql
spec:
nodeSelector:
kubernetes.io/os: linux
containers:
- name: mysql
image: mysql:5.7
args:
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
- "--ignore-db-dir=lost+found"
env:
- name: MYSQL_DATABASE
value: onedev
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: onedev-mysql
key: password
ports:
- containerPort: 3306
resources:
requests:
memory: 256Mi
volumeMounts:
- name: mysql
mountPath: /var/lib/mysql
readinessProbe:
exec:
command:
- bash
- "-c"
- |
mysql -uroot -p$MYSQL_ROOT_PASSWORD -e 'SELECT 1'
initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1
volumes:
- name: mysql
persistentVolumeClaim:
claimName: onedev-mysql # change this if your pvc name is different
Now lets configure the paramaters for our new installation. Download file values.yaml and make below changes:
databse
database:
external: true
type: "mysql"
host: "onedev-mysql.onedev.svc.cluster.local"
port: "3306"
name: "onedev"
user: "root"
password: "<password>"
maximumPoolSize: "25"persistance
persistence:
enabled: true
# Name of an existing PersistentVolumeClaim we got from our cluster.
existingClaim: "onedev"Save the file with above changes (remember to change dbPassword) and any other parameters you want to configure
With this information we can proceed to uninstall our current onedev release
helm uninstall onedev -n onedev
Wait for the pods to get terminated.
Lets apply the mysql.yaml we saved earlier with kubectl
kubectl apply -f mysql.yaml -n onedev
This action will install MySQL as seperate deployment, effectively separating MySQL from the release. Wait for the database pod to come online and in ready state.
Install OneDev 8.6.13 with our configuration file
helm install onedev onedev/onedev -n onedev --version 8.6.13 -f /path/to/values.yaml
Follow this procedure to upgrade 8.6.13 to latest version