1
+ {{- range $jobName, $job := $.Values.hydra.customMigrations.jobs }}
2
+ {{- if $job.enabled -}}
3
+ {{- $nodeSelector := ternary $job.nodeSelector $.Values.job.nodeSelector (not (empty $job.nodeSelector)) -}}
4
+ {{- $migrationExtraEnv := ternary $job.extraEnv $.Values.job.extraEnv (not (empty $job.extraEnv)) -}}
5
+ {{- $resources := ternary $job.resources $.Values.job.resources (not (empty $job.resources)) -}}
6
+ {{- $annotations := merge $.Values.job.annotations (default dict $job.annotations) -}}
7
+ {{- $labels := merge $.Values.job.labels (default dict $job.labels) -}}
8
+
9
+ ---
10
+ apiVersion : batch/v1
11
+ kind : Job
12
+ metadata :
13
+ name : {{ include "hydra.fullname" $ }}-{{ $jobName }}
14
+ {{- if $.Release.Namespace }}
15
+ namespace : {{ $.Release.Namespace }}
16
+ {{- end }}
17
+ labels :
18
+ {{- include "hydra.labels" $ | nindent 4 }}
19
+ {{- with $labels }}
20
+ {{- toYaml . | nindent 4 }}
21
+ {{- end }}
22
+ annotations :
23
+ {{- with $annotations }}
24
+ {{- toYaml . | nindent 4 }}
25
+ {{- end }}
26
+ spec :
27
+ template :
28
+ metadata :
29
+ annotations :
30
+ {{- with $annotations }}
31
+ {{- toYaml . | nindent 8 }}
32
+ {{- end }}
33
+ {{- with $.Values.job.podMetadata.annotations }}
34
+ {{- toYaml . | nindent 8 }}
35
+ {{- end }}
36
+ labels :
37
+ app.kubernetes.io/name : {{ include "hydra.fullname" $ }}-{{ $jobName }}-automigrate
38
+ app.kubernetes.io/instance : {{ $.Release.Name }}
39
+ {{- with $labels }}
40
+ {{- toYaml . | nindent 8 }}
41
+ {{- end }}
42
+ {{- with $.Values.job.podMetadata.labels }}
43
+ {{- toYaml . | nindent 8 }}
44
+ {{- end }}
45
+ spec :
46
+ {{- with $.Values.imagePullSecrets }}
47
+ imagePullSecrets :
48
+ {{- toYaml . | nindent 8 }}
49
+ {{- end }}
50
+ serviceAccountName : {{ include "hydra.job.serviceAccountName" $ }}
51
+ automountServiceAccountToken : {{ $.Values.job.automountServiceAccountToken }}
52
+ containers :
53
+ - name : {{ $.Chart.Name }}-{{ $jobName }}
54
+ image : " {{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
55
+ imagePullPolicy : {{ $.Values.image.pullPolicy }}
56
+ {{- if $job.customCommand }}
57
+ command : {{- toYaml $job.customCommand | nindent 10 }}
58
+ {{- else }}
59
+ command : ["hydra"]
60
+ {{- end }}
61
+ args : {{- toYaml $job.customArgs | nindent 10 }}
62
+ env :
63
+ {{- if not (empty ( include "hydra.dsn" $ )) }}
64
+ {{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
65
+ - name : DSN
66
+ valueFrom :
67
+ secretKeyRef :
68
+ name : {{ include "hydra.secretname" $ }}
69
+ key : dsn
70
+ {{- end }}
71
+ {{- end }}
72
+ {{- with $migrationExtraEnv }}
73
+ {{- toYaml . | nindent 10 }}
74
+ {{- end }}
75
+ lifecycle :
76
+ {{- if $.Values.job.lifecycle }}
77
+ {{- tpl $.Values.job.lifecycle $ | nindent 10 }}
78
+ {{- end }}
79
+ {{- with $.Values.deployment.securityContext }}
80
+ securityContext :
81
+ {{- toYaml . | nindent 10 }}
82
+ {{- end }}
83
+ {{- with $resources }}
84
+ resources :
85
+ {{- toYaml . | nindent 10 }}
86
+ {{- end }}
87
+ volumeMounts :
88
+ - name : {{ include "hydra.name" $ }}-config-volume
89
+ mountPath : /etc/config
90
+ readOnly : true
91
+ {{- if $job.extraVolumeMounts }}
92
+ {{- toYaml $job.extraVolumeMounts | nindent 12 }}
93
+ {{- else if $.Values.deployment.extraVolumeMounts }}
94
+ {{- toYaml $.Values.deployment.extraVolumeMounts | nindent 12 }}
95
+ {{- end }}
96
+ {{- if $.Values.job.extraContainers }}
97
+ {{- tpl $.Values.job.extraContainers $ | nindent 6 }}
98
+ {{- end }}
99
+ {{- if $.Values.job.extraInitContainers }}
100
+ initContainers :
101
+ {{- tpl $.Values.job.extraInitContainers $ | nindent 8 }}
102
+ {{- end }}
103
+ restartPolicy : Never
104
+ {{- with $.Values.deployment.podSecurityContext }}
105
+ securityContext :
106
+ {{- toYaml . | nindent 8 }}
107
+ {{- end }}
108
+ shareProcessNamespace : {{ $.Values.job.shareProcessNamespace }}
109
+ volumes :
110
+ - name : {{ include "hydra.name" $ }}-config-volume
111
+ configMap :
112
+ name : {{ include "hydra.fullname" $ }}-migrate
113
+ {{- if $job.extraVolumes }}
114
+ {{- toYaml $job.extraVolumes | nindent 8 }}
115
+ {{- else if $.Values.deployment.extraVolumes }}
116
+ {{- toYaml $.Values.deployment.extraVolumes | nindent 8 }}
117
+ {{- end }}
118
+ {{- with $nodeSelector }}
119
+ nodeSelector :
120
+ {{- toYaml . | nindent 8 }}
121
+ {{- end }}
122
+ {{- with $.Values.job.tolerations }}
123
+ tolerations :
124
+ {{- toYaml . | nindent 8 }}
125
+ {{- end }}
126
+ backoffLimit : {{ $.Values.job.spec.backoffLimit }}
127
+ {{- end }}
128
+ {{- end }}
0 commit comments