J release changes
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / templates / migrations-pre-upgrade.yaml
1 {{- if .Values.deployment.kong.enabled }}
2 {{- if (and .Values.migrations.preUpgrade (not (eq .Values.env.database "off"))) }}
3 # Why is this Job duplicated and not using only helm hooks?
4 # See: https://github.com/helm/charts/pull/7362
5 apiVersion: batch/v1
6 kind: Job
7 metadata:
8   name: {{ template "kong.fullname" . }}-pre-upgrade-migrations
9   namespace: {{ template "kong.namespace" . }}
10   labels:
11     {{- include "kong.metaLabels" . | nindent 4 }}
12     app.kubernetes.io/component: pre-upgrade-migrations
13   annotations:
14     helm.sh/hook: "pre-upgrade"
15     helm.sh/hook-delete-policy: "before-hook-creation"
16     argocd.argoproj.io/hook: Sync
17     argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
18   {{- range $key, $value := .Values.migrations.jobAnnotations }}
19     {{ $key }}: {{ $value | quote }}
20   {{- end }}
21 spec:
22   backoffLimit: {{ .Values.migrations.backoffLimit }}
23   template:
24     metadata:
25       name: {{ template "kong.name" . }}-pre-upgrade-migrations
26       labels:
27         {{- include "kong.metaLabels" . | nindent 8 }}
28         app.kubernetes.io/component: pre-upgrade-migrations
29       {{- if .Values.migrations.annotations }}
30       annotations:
31       {{- range $key, $value := .Values.migrations.annotations }}
32         {{ $key }}: {{ $value | quote }}
33       {{- end }}
34       {{- if (and (not .Values.deployment.serviceAccount.automountServiceAccountToken) (or .Values.deployment.serviceAccount.create .Values.deployment.serviceAccount.name)) }}
35         kuma.io/service-account-token-volume: {{ template "kong.serviceAccountTokenName" . }}
36       {{- end }}
37       {{- end }}
38     spec:
39       {{- if or .Values.deployment.serviceAccount.create .Values.deployment.serviceAccount.name }}
40       serviceAccountName: {{ template "kong.serviceAccountName" . }}
41       {{- end }}
42       {{- if (and (or .Values.deployment.serviceAccount.create .Values.deployment.serviceAccount.name) .Values.deployment.serviceAccount.automountServiceAccountToken) }}
43       automountServiceAccountToken: true
44       {{- else }}
45       automountServiceAccountToken: false
46       {{ end }}
47       {{- if .Values.image.pullSecrets }}
48       imagePullSecrets:
49       {{- range .Values.image.pullSecrets }}
50         - name: {{ . }}
51       {{- end }}
52       {{- end }}
53       {{- if (or (and (.Values.postgresql.enabled) .Values.waitImage.enabled) .Values.deployment.initContainers) }}
54       initContainers:
55       {{- if .Values.deployment.initContainers }}
56       {{- toYaml .Values.deployment.initContainers | nindent 6 }}
57       {{- end }}
58       {{- if (and (.Values.postgresql.enabled) .Values.waitImage.enabled) }}
59       {{- include "kong.wait-for-postgres" . | nindent 6 }}
60       {{- end }}
61       {{- end }}
62       containers:
63       {{- if .Values.migrations.sidecarContainers }}
64       {{- toYaml .Values.migrations.sidecarContainers | nindent 6 }}
65       {{- end }}
66       - name: {{ template "kong.name" . }}-upgrade-migrations
67         image: {{ include "kong.getRepoTag" .Values.image }}
68         imagePullPolicy: {{ .Values.image.pullPolicy }}
69         securityContext:
70         {{ toYaml .Values.containerSecurityContext | nindent 10 }}
71         env:
72         {{- include "kong.no_daemon_env" . | nindent 8 }}
73         {{- include "kong.envFrom" .Values.envFrom | nindent 8 }}
74         args: [ "kong", "migrations", "up" ]
75         volumeMounts:
76         {{- include "kong.volumeMounts" . | nindent 8 }}
77         {{- include "kong.userDefinedVolumeMounts" .Values.deployment | nindent 8 }}
78         resources:
79         {{- toYaml .Values.migrations.resources| nindent 10 }}
80       securityContext:
81       {{- include "kong.podsecuritycontext" . | nindent 8 }}
82       {{- if .Values.affinity }}
83       affinity:
84       {{- toYaml .Values.affinity | nindent 8 }}
85       {{- end }}
86       {{- if .Values.nodeSelector }}
87       nodeSelector:
88       {{- toYaml .Values.nodeSelector | nindent 8 }}
89       {{- end }}
90       {{- if .Values.tolerations }}
91       tolerations:
92       {{- toYaml .Values.tolerations | nindent 8 }}
93       {{- end }}
94       restartPolicy: OnFailure
95       volumes:
96       {{- include "kong.volumes" . | nindent 6 -}}
97       {{- include "kong.userDefinedVolumes" . | nindent 6 -}}
98 {{- end }}
99 {{- end }}