tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 1 | apiVersion: batch/v1 |
| 2 | kind: Job |
| 3 | metadata: |
| 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 |
| 9 | spec: |
| 10 | template: |
| 11 | spec: |
| 12 | securityContext: |
| 13 | fsGroup: 1001 |
| 14 | runAsUser: 1001 |
| 15 | containers: |
| 16 | - name: mariadb-job-pre-upgrade |
Sylvain Desbureaux | 4106614 | 2020-11-19 17:12:46 +0100 | [diff] [blame] | 17 | image: {{ include "repositoryGenerator.image.kubectl" . }} |
tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 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 | --- |
| 37 | apiVersion: batch/v1 |
| 38 | kind: Job |
| 39 | metadata: |
| 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 |
| 45 | spec: |
| 46 | template: |
| 47 | spec: |
| 48 | securityContext: |
| 49 | fsGroup: 1001 |
| 50 | runAsUser: 0 |
| 51 | initContainers: |
Sylvain Desbureaux | 4106614 | 2020-11-19 17:12:46 +0100 | [diff] [blame] | 52 | - image: {{ include "repositoryGenerator.image.readiness" . }} |
tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 53 | name: mariadb-galera-upgrade-readiness |
| 54 | env: |
| 55 | - name: NAMESPACE |
| 56 | valueFrom: |
| 57 | fieldRef: |
| 58 | apiVersion: v1 |
| 59 | fieldPath: metadata.namespace |
| 60 | command: |
Sylvain Desbureaux | 1694e1d | 2020-08-21 09:58:25 +0200 | [diff] [blame] | 61 | - /app/ready.py |
tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 62 | args: |
| 63 | - --container-name |
| 64 | - mariadb-galera |
| 65 | containers: |
| 66 | - name: mariadb-job-post-upgrade |
Sylvain Desbureaux | 4106614 | 2020-11-19 17:12:46 +0100 | [diff] [blame] | 67 | image: {{ include "repositoryGenerator.image.kubectl" . }} |
tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 68 | imagePullPolicy: IfNotPresent |
| 69 | env: |
| 70 | - name: NAMESPACE_ENV |
| 71 | valueFrom: |
| 72 | fieldRef: |
| 73 | apiVersion: v1 |
| 74 | fieldPath: metadata.namespace |
Marat Salakhutdinov | a72170b | 2020-06-27 23:18:17 -0400 | [diff] [blame] | 75 | - name: REPLICA_COUNT |
| 76 | value: "{{ .Values.replicaCount }}" |
tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 77 | 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 | --- |
| 89 | apiVersion: batch/v1 |
| 90 | kind: Job |
| 91 | metadata: |
| 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 |
| 97 | spec: |
| 98 | template: |
| 99 | spec: |
| 100 | containers: |
| 101 | - name: mariadb-job-post-delete |
Sylvain Desbureaux | 4106614 | 2020-11-19 17:12:46 +0100 | [diff] [blame] | 102 | image: {{ include "repositoryGenerator.image.kubectl" . }} |
tringuyen | eb9eb59 | 2020-04-01 17:51:06 +0000 | [diff] [blame] | 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 |