Skip to content

Migration

Migrate an existing instance on a new one

Create the job manifest file "./job.migration.yaml" using the following as an example :

---
apiVersion: batch/v1
kind: Job
metadata:
  name: znuny-migration-db2db
spec:
  template:
    spec:
      containers:
        - name: zcli
          image: ghcr.io/fr-bez-aosc/znuny:<tag>
          envFrom:
          - configMapRef:
              name: znuny-config
          - secretRef:
              name: znuny-secrets
          command:
            - "/usr/bin/zcli"
            - "job"
            - "migration"
            - "database"
            - "-h"
            - "<postgresql host>"                                     # The kubernetes domain of the remote database
            - "-p"
            - "<postgresql port>"                                     # The port exposed by the kubernetes service
            - "-n"
            - "<postgresql database>"                                 # The name of the remote database
            - "-u"
            - "<postgresql user>"                                     # The user used for the remote connection
            - "-w"
            - "<postgresql password>"                                 # The user's password used for the remote connection
      restartPolicy: Never

Make sure the image used is the same version as the target deployment.

Stop the new instance :

kubectl scale deployment <deployment name> --replicas=0

Migrate migrate the database :

kubectl create \
  -f ./tests/job.migration.yaml

Restart the new instance :

kubectl scale deployment <deployment name> --replicas=1

If desired, delete the migration job to clean pods :

kubectl delete \
  -f ./tests/job.migration.yaml