blob: 5dc822a66f5865dcb277a35f8cfaffceb9626768 [file] [log] [blame]
tringuyeneb9eb592020-04-01 17:51:06 +00001apiVersion: batch/v1
2kind: Job
3metadata:
4 name: {{ include "common.fullname" . }}-pre-upgrade
5 annotations:
6 "helm.sh/hook": "pre-upgrade"
7 "helm.sh/hook-weight": "1"
8 "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
9spec:
10 template:
11 spec:
12 securityContext:
13 fsGroup: 1001
14 runAsUser: 1001
15 containers:
16 - name: mariadb-job-pre-upgrade
17 image: {{ .Values.global.kubectlImage}}
18 imagePullPolicy: IfNotPresent
19 env:
20 - name: NAMESPACE_ENV
21 valueFrom:
22 fieldRef:
23 apiVersion: v1
24 fieldPath: metadata.namespace
25 command: ["/bin/bash", "-c", "--"]
26 args: ["/upgrade/upgrade-scripts.sh"]
27 volumeMounts:
28 - name: config-mariadb-upgrade
29 mountPath: /upgrade
30 volumes:
31 - name: config-mariadb-upgrade
32 configMap:
33 name: {{ include "common.fullname" . }}-upgrade-deployment
34 defaultMode: 0777
35 restartPolicy: OnFailure
36---
37apiVersion: batch/v1
38kind: Job
39metadata:
40 name: {{ include "common.fullname" . }}-post-upgrade
41 annotations:
42 "helm.sh/hook": "post-upgrade"
43 "helm.sh/hook-weight": "1"
44 "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
45spec:
46 template:
47 spec:
48 securityContext:
49 fsGroup: 1001
50 runAsUser: 0
51 initContainers:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020052 - image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
tringuyeneb9eb592020-04-01 17:51:06 +000053 name: mariadb-galera-upgrade-readiness
54 env:
55 - name: NAMESPACE
56 valueFrom:
57 fieldRef:
58 apiVersion: v1
59 fieldPath: metadata.namespace
60 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020061 - /app/ready.py
tringuyeneb9eb592020-04-01 17:51:06 +000062 args:
63 - --container-name
64 - mariadb-galera
65 containers:
66 - name: mariadb-job-post-upgrade
67 image: {{ .Values.global.kubectlImage}}
68 imagePullPolicy: IfNotPresent
69 env:
70 - name: NAMESPACE_ENV
71 valueFrom:
72 fieldRef:
73 apiVersion: v1
74 fieldPath: metadata.namespace
Marat Salakhutdinova72170b2020-06-27 23:18:17 -040075 - name: REPLICA_COUNT
76 value: "{{ .Values.replicaCount }}"
tringuyeneb9eb592020-04-01 17:51:06 +000077 command: ["/bin/bash", "-c", "--"]
78 args: ["/upgrade/post-upgrade-script.sh"]
79 volumeMounts:
80 - name: config-mariadb-upgrade
81 mountPath: /upgrade
82 volumes:
83 - name: config-mariadb-upgrade
84 configMap:
85 name: {{ include "common.fullname" . }}-post-upgrade-deployment
86 defaultMode: 0777
87 restartPolicy: OnFailure
88---
89apiVersion: batch/v1
90kind: Job
91metadata:
92 name: {{ include "common.fullname" . }}-post-delete
93 annotations:
94 "helm.sh/hook": "post-delete"
95 "helm.sh/hook-weight": "1"
96 "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
97spec:
98 template:
99 spec:
100 containers:
101 - name: mariadb-job-post-delete
102 image: {{ .Values.global.kubectlImage}}
103 imagePullPolicy: IfNotPresent
104 command: ["/bin/bash", "-c", "--"]
105 args:
106 - for ((index=0;index<{{ $.Values.replicaCount }};index+=1));
107 do kubectl delete pvc "{{ include "common.fullname" . }}-data-{{ include "common.fullname" . }}-$index";
108 done; kubectl delete deployment {{ include "common.fullname" . }}-upgrade-deployment;
109 restartPolicy: OnFailure