diff --git a/liquid-code-chart/templates/pre-install-drob.yaml b/liquid-code-chart/templates/pre-install-drob.yaml new file mode 100644 index 0000000..40e7744 --- /dev/null +++ b/liquid-code-chart/templates/pre-install-drob.yaml @@ -0,0 +1,41 @@ +{{ if .Values.database.dropDb }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{.Release.Name}}-drop-job + labels: + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "-1" + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +spec: + template: + metadata: + name: {{.Release.Name}}-migration-pod + labels: + app.kubernetes.io/managed-by: {{.Release.Service | quote }} + app.kubernetes.io/instance: {{.Release.Name | quote }} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" + spec: + restartPolicy: Never + containers: + - name: {{ .Release.Name }}-backend + image: ghcr.io/nullptroma/liquid-backend:1.0.0 + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: PG_URI + valueFrom: + secretKeyRef: + name: {{ required "Cluster creds secret required!" .Values.database.secretName }} + key: uri + - name: DROP_DATABASE + value: "1" + imagePullSecrets: + - name: github-registry +{{ end }} \ No newline at end of file diff --git a/liquid-code-chart/templates/pre-install-migration.yaml b/liquid-code-chart/templates/pre-install-migration.yaml index 67514c3..e431bfc 100644 --- a/liquid-code-chart/templates/pre-install-migration.yaml +++ b/liquid-code-chart/templates/pre-install-migration.yaml @@ -1,3 +1,4 @@ +{{ if .Values.database.migrateDb }} apiVersion: batch/v1 kind: Job metadata: @@ -35,4 +36,5 @@ spec: - name: MIGRATE_ONLY value: "1" imagePullSecrets: - - name: github-registry \ No newline at end of file + - name: github-registry +{{ end }} \ No newline at end of file diff --git a/liquid-code-chart/values.yaml b/liquid-code-chart/values.yaml index 692b39a..b6b7a30 100644 --- a/liquid-code-chart/values.yaml +++ b/liquid-code-chart/values.yaml @@ -7,4 +7,6 @@ jwt: secretName: jwt-secrets database: secretName: liquid-db-app + migrateDb: true + dropDb: false imagePullSecret: github-registry