forked from PrefectHQ/prefect-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-upgrade-hook.yaml
More file actions
88 lines (88 loc) · 4.03 KB
/
pre-upgrade-hook.yaml
File metadata and controls
88 lines (88 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{{- if and .Values.backgroundServices.runAsSeparateDeployment (not .Values.sqlite.enabled) .Values.migrations.enabled -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "common.names.fullname" . }}-db-migrations
namespace: {{ .Release.Namespace }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
prefect-version: {{ .Chart.AppVersion }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
app.kubernetes.io/component: pre-upgrade-hook
annotations:
"helm.sh/hook": post-install,pre-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
{{- if .Values.migrations.timeoutSeconds }}
activeDeadlineSeconds: {{ .Values.migrations.timeoutSeconds }}
{{- end }}
backoffLimit: {{ .Values.migrations.backoffLimit }}
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: pre-upgrade-hook
prefect-version: {{ .Chart.AppVersion }}
{{- if .Values.migrations.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.migrations.podLabels "context" $) | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "server.serviceAccountName" . }}
restartPolicy: {{ .Values.migrations.restartPolicy }}
containers:
- name: pre-upgrade-migration
image: "{{ .Values.global.prefect.image.repository }}:{{ .Values.global.prefect.image.prefectTag }}"
imagePullPolicy: {{ .Values.global.prefect.image.pullPolicy }}
{{- if .Values.migrations.entrypoint }}
command: {{- toYaml .Values.migrations.entrypoint | nindent 10 }}
{{- end }}
args:
- |
set -eo pipefail
echo "Starting database migration..."
{{- tpl .Values.migrations.command . | nindent 10 }}
env:
- name: PREFECT_API_DATABASE_CONNECTION_URL
valueFrom:
secretKeyRef:
name: {{ include "server.postgres-string-secret-name" . }}
key: connection-string
- name: HOME
value: /home/prefect
{{- if .Values.global.prefect.env }}
{{- include "common.tplvalues.render" (dict "value" .Values.global.prefect.env "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.server.env }}
{{- include "common.tplvalues.render" (dict "value" .Values.server.env "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.migrations.env }}
{{- include "common.tplvalues.render" (dict "value" .Values.migrations.env "context" $) | nindent 8 }}
{{- end }}
resources: {{- toYaml .Values.migrations.resources | nindent 10 }}
securityContext: {{- toYaml .Values.migrations.securityContext | nindent 10 }}
{{- if .Values.migrations.extraVolumeMounts }}
volumeMounts: {{- toYaml .Values.migrations.extraVolumeMounts | nindent 10 }}
{{- end }}
{{- if .Values.migrations.extraVolumes }}
volumes: {{- toYaml .Values.migrations.extraVolumes | nindent 8 }}
{{- end }}
{{- if .Values.migrations.affinity }}
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.migrations.affinity "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.migrations.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.migrations.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.migrations.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.migrations.tolerations "context" .) | nindent 8 }}
{{- end }}
{{- if .Values.global.prefect.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.global.prefect.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.backgroundServices.podSecurityContext }}
{{- include . | nindent 4 }}
{{- end }}
{{- end }}