blob: cc71bb855cad80e272611d11c8b3c48de5cce5c4 [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:
52 - image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
53 name: mariadb-galera-upgrade-readiness
54 env:
55 - name: NAMESPACE
56 valueFrom:
57 fieldRef:
58 apiVersion: v1
59 fieldPath: metadata.namespace
60 command:
61 - /root/ready.py
62 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
75 command: ["/bin/bash", "-c", "--"]
76 args: ["/upgrade/post-upgrade-script.sh"]
77 volumeMounts:
78 - name: config-mariadb-upgrade
79 mountPath: /upgrade
80 volumes:
81 - name: config-mariadb-upgrade
82 configMap:
83 name: {{ include "common.fullname" . }}-post-upgrade-deployment
84 defaultMode: 0777
85 restartPolicy: OnFailure
86---
87apiVersion: batch/v1
88kind: Job
89metadata:
90 name: {{ include "common.fullname" . }}-post-delete
91 annotations:
92 "helm.sh/hook": "post-delete"
93 "helm.sh/hook-weight": "1"
94 "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
95spec:
96 template:
97 spec:
98 containers:
99 - name: mariadb-job-post-delete
100 image: {{ .Values.global.kubectlImage}}
101 imagePullPolicy: IfNotPresent
102 command: ["/bin/bash", "-c", "--"]
103 args:
104 - for ((index=0;index<{{ $.Values.replicaCount }};index+=1));
105 do kubectl delete pvc "{{ include "common.fullname" . }}-data-{{ include "common.fullname" . }}-$index";
106 done; kubectl delete deployment {{ include "common.fullname" . }}-upgrade-deployment;
107 restartPolicy: OnFailure