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