From a0ee73dec3250334cc2293ff7ecddfc7b7d7e699 Mon Sep 17 00:00:00 2001 From: sdarwin Date: Mon, 10 Apr 2023 13:27:19 -0600 Subject: [PATCH] Move helm database migrations to Job --- kube/boost/templates/migration-job.yaml | 30 +++++++++++++++++++++++++ kube/boost/values.yaml | 5 +++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 kube/boost/templates/migration-job.yaml diff --git a/kube/boost/templates/migration-job.yaml b/kube/boost/templates/migration-job.yaml new file mode 100644 index 00000000..8d863736 --- /dev/null +++ b/kube/boost/templates/migration-job.yaml @@ -0,0 +1,30 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: database-migrations-job + labels: + env: {{ .Values.deploymentEnvironment }} + app: boost + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "-1" +spec: + ttlSecondsAfterFinished: 3600 + backoffLimit: 4 + template: + spec: + restartPolicy: OnFailure + volumes: +{{ toYaml .Values.Volumes | indent 6 }} + imagePullSecrets: + - name: revsys-docker-registry + containers: + - name: database-migrations + image: {{ .Values.Image }}:{{ .Values.ImageTag }} + command: ["/bin/sh", "-c"] + args: + - "./manage.py migrate --noinput" + env: +{{ toYaml .Values.Env | indent 10 }} + volumeMounts: +{{ toYaml .Values.VolumeMounts | indent 10 }} diff --git a/kube/boost/values.yaml b/kube/boost/values.yaml index e16780bd..2b6a8dd9 100644 --- a/kube/boost/values.yaml +++ b/kube/boost/values.yaml @@ -15,8 +15,9 @@ replicaCount: "2" # where necessary initCommands: - - name: migrate - command: ./manage.py migrate --noinput + # migrate moved to a Job + # - name: migrate + # command: ./manage.py migrate --noinput - name: collectstatic command: ./manage.py collectstatic --noinput