Jakub Latusek | 44f0fdd | 2020-10-21 13:36:29 +0200 | [diff] [blame] | 1 | {{/* |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 2 | # Copyright © 2017 Amdocs, Bell Canada |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
Jakub Latusek | 44f0fdd | 2020-10-21 13:36:29 +0200 | [diff] [blame] | 15 | */}} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 16 | {{- if .Values.global.migration.enabled }} |
| 17 | apiVersion: batch/v1 |
| 18 | kind: Job |
| 19 | metadata: |
| 20 | name: {{ include "common.fullname" . }}-backup |
| 21 | namespace: {{ include "common.namespace" . }} |
| 22 | labels: |
| 23 | app: {{ include "common.name" . }} |
| 24 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 25 | release: {{ include "common.release" . }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 26 | heritage: {{ .Release.Service }} |
| 27 | annotations: |
| 28 | "helm.sh/hook": pre-upgrade,pre-install |
| 29 | "helm.sh/hook-weight": "1" |
| 30 | "helm.sh/hook-delete-policy": before-hook-creation |
| 31 | spec: |
| 32 | backoffLimit: 20 |
| 33 | template: |
| 34 | metadata: |
| 35 | labels: |
| 36 | app: {{ include "common.name" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 37 | release: {{ include "common.release" . }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 38 | name: {{ include "common.name" . }} |
| 39 | spec: |
| 40 | containers: |
| 41 | - name: {{ include "common.fullname" . }} |
Sylvain Desbureaux | 0d2cf1a | 2022-01-05 16:08:27 +0100 | [diff] [blame] | 42 | image: {{ include "repositoryGenerator.image.mariadb" . }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 43 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 44 | env: |
| 45 | - name: DB_HOST |
| 46 | value: {{ .Values.global.migration.dbHost }} |
| 47 | - name: DB_USER |
Krzysztof Opasiak | 587b6e6 | 2020-03-24 03:26:03 +0100 | [diff] [blame] | 48 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-backup-creds" "key" "login") | indent 10 }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 49 | - name: DB_PORT |
| 50 | value: "{{ .Values.global.migration.dbPort }}" |
| 51 | - name: DB_PASS |
Krzysztof Opasiak | 587b6e6 | 2020-03-24 03:26:03 +0100 | [diff] [blame] | 52 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-backup-creds" "key" "password") | indent 10 }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 53 | command: |
| 54 | - /bin/bash |
| 55 | - -c |
Andreas Geissler | 17be962 | 2022-04-29 13:33:02 +0200 | [diff] [blame^] | 56 | - | |
| 57 | {{- if include "common.onServiceMesh" . }} |
| 58 | echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }} |
| 59 | mysqldump -vv --user=${DB_USER} --password=${DB_PASS} --host=${DB_HOST} --port=${DB_PORT} --databases --single-transaction --quick --lock-tables=false catalogdb requestdb nfvo > /var/data/mariadb/backup-`date +%s`.sql |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 60 | volumeMounts: |
| 61 | - mountPath: /etc/localtime |
| 62 | name: localtime |
| 63 | readOnly: true |
| 64 | - name: backup-storage |
| 65 | mountPath: /var/data/mariadb |
Andreas Geissler | 17be962 | 2022-04-29 13:33:02 +0200 | [diff] [blame^] | 66 | {{ include "common.waitForJobContainer" . | indent 6 | trim }} |
farida azmy | 87f4622 | 2021-04-06 15:25:15 +0200 | [diff] [blame] | 67 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 68 | volumes: |
| 69 | - name: localtime |
| 70 | hostPath: |
| 71 | path: /etc/localtime |
| 72 | - name: backup-storage |
| 73 | persistentVolumeClaim: |
| 74 | claimName: {{ include "common.fullname" . }}-migration |
| 75 | imagePullSecrets: |
| 76 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |
| 77 | restartPolicy: Never |
| 78 | --- |
| 79 | {{- end }} |
| 80 | apiVersion: batch/v1 |
| 81 | kind: Job |
| 82 | metadata: |
| 83 | name: {{ include "common.fullname" . }}-config-job |
| 84 | namespace: {{ include "common.namespace" . }} |
| 85 | labels: |
| 86 | app: {{ include "common.name" . }} |
| 87 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 88 | release: {{ include "common.release" . }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 89 | heritage: {{ .Release.Service }} |
| 90 | annotations: |
| 91 | "helm.sh/hook": post-upgrade,post-rollback,post-install |
| 92 | "helm.sh/hook-weight": "0" |
| 93 | "helm.sh/hook-delete-policy": before-hook-creation |
| 94 | spec: |
| 95 | backoffLimit: 20 |
| 96 | template: |
| 97 | metadata: |
| 98 | labels: |
| 99 | app: {{ include "common.name" . }}-job |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 100 | release: {{ include "common.release" . }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 101 | name: {{ include "common.name" . }} |
| 102 | spec: |
Sylvain Desbureaux | d055a17 | 2020-10-30 14:32:03 +0100 | [diff] [blame] | 103 | initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 104 | containers: |
Sylvain Desbureaux | d055a17 | 2020-10-30 14:32:03 +0100 | [diff] [blame] | 105 | - name: {{ include "common.name" . }}-config |
Sylvain Desbureaux | 747982c | 2020-11-19 17:40:05 +0100 | [diff] [blame] | 106 | image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 107 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 108 | command: |
| 109 | - /bin/bash |
| 110 | - -c |
| 111 | - > |
Andreas Geissler | 17be962 | 2022-04-29 13:33:02 +0200 | [diff] [blame^] | 112 | {{- if include "common.onServiceMesh" . }} |
| 113 | echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 114 | mysql() { /usr/bin/mysql -h ${DB_HOST} -P ${DB_PORT} "$@"; }; |
| 115 | export -f mysql; |
| 116 | mysql --user=root --password=${MYSQL_ROOT_PASSWORD} requestdb -e exit > /dev/null 2>&1 {{ if not .Values.global.migration.enabled }} && echo "Database already initialized!!!" && exit 0 {{ end }}; |
| 117 | for f in /docker-entrypoint-initdb.d/*; do case "$f" in *.sh) echo "$0: running $f"; . "$f" ;; *.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; esac; echo; done; |
| 118 | {{- if .Values.global.migration.enabled }} |
| 119 | mysql -vv --user=root --password=${MYSQL_ROOT_PASSWORD} < `ls -tr /var/data/mariadb/* | tail -1`; |
| 120 | {{- end }} |
| 121 | env: |
| 122 | - name: DB_HOST |
krishnaa96 | 92b606b | 2020-10-30 11:29:21 +0530 | [diff] [blame] | 123 | value: {{ include "common.mariadbService" . }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 124 | - name: DB_PORT |
krishnaa96 | 92b606b | 2020-10-30 11:29:21 +0530 | [diff] [blame] | 125 | value: {{ include "common.mariadbPort" . | quote }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 126 | - name: MYSQL_ROOT_PASSWORD |
Krzysztof Opasiak | 587b6e6 | 2020-03-24 03:26:03 +0100 | [diff] [blame] | 127 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-pass" "key" "password") | indent 10 }} |
Krzysztof Opasiak | f68b728 | 2020-03-25 23:22:46 +0100 | [diff] [blame] | 128 | - name: DB_USER |
| 129 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "login") | indent 10 }} |
| 130 | - name: DB_PASSWORD |
| 131 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "password") | indent 10 }} |
| 132 | - name: DB_ADMIN |
| 133 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "login") | indent 10 }} |
| 134 | - name: DB_ADMIN_PASSWORD |
| 135 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "password") | indent 10 }} |
| 136 | - name: CAMUNDA_DB_USER |
| 137 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "camunda-db-creds" "key" "login") | indent 10 }} |
| 138 | - name: CAMUNDA_DB_PASSWORD |
| 139 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "camunda-db-creds" "key" "password") | indent 10 }} |
| 140 | - name: REQUEST_DB_USER |
| 141 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "request-db-creds" "key" "login") | indent 10 }} |
| 142 | - name: REQUEST_DB_PASSWORD |
| 143 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "request-db-creds" "key" "password") | indent 10 }} |
| 144 | - name: CATALOG_DB_USER |
| 145 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "catalog-db-creds" "key" "login") | indent 10 }} |
| 146 | - name: CATALOG_DB_PASSWORD |
| 147 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "catalog-db-creds" "key" "password") | indent 10 }} |
rope252 | 4df5519 | 2020-08-24 13:55:58 +0100 | [diff] [blame] | 148 | - name: NFVO_DB_USER |
| 149 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "nfvo-db-creds" "key" "login") | indent 10 }} |
| 150 | - name: NFVO_DB_PASSWORD |
| 151 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "nfvo-db-creds" "key" "password") | indent 10 }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 152 | volumeMounts: |
| 153 | - mountPath: /etc/localtime |
| 154 | name: localtime |
| 155 | readOnly: true |
Tomáš Levora | 2a63ef3 | 2019-09-20 08:16:54 +0200 | [diff] [blame] | 156 | - name: docker-entrypoint-initdb-d-sh |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 157 | mountPath: "/docker-entrypoint-initdb.d" |
Tomáš Levora | 2a63ef3 | 2019-09-20 08:16:54 +0200 | [diff] [blame] | 158 | - name: docker-entrypoint-initdb-d-sql |
| 159 | mountPath: "/docker-entrypoint-initdb.d/db-sql-scripts" |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 160 | {{- if .Values.global.migration.enabled }} |
| 161 | - name: backup-storage |
| 162 | mountPath: /var/data/mariadb |
| 163 | {{- end }} |
| 164 | resources: |
| 165 | {{ include "common.resources" . | indent 12 }} |
Andreas Geissler | 17be962 | 2022-04-29 13:33:02 +0200 | [diff] [blame^] | 166 | {{ include "common.waitForJobContainer" . | indent 6 | trim }} |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 167 | {{- if .Values.nodeSelector }} |
| 168 | nodeSelector: |
| 169 | {{ toYaml .Values.nodeSelector | indent 10 }} |
| 170 | {{- end -}} |
| 171 | {{- if .Values.affinity }} |
| 172 | affinity: |
| 173 | {{ toYaml .Values.affinity | indent 10 }} |
| 174 | {{- end }} |
| 175 | volumes: |
| 176 | - name: localtime |
| 177 | hostPath: |
| 178 | path: /etc/localtime |
Tomáš Levora | 2a63ef3 | 2019-09-20 08:16:54 +0200 | [diff] [blame] | 179 | - name: docker-entrypoint-initdb-d-sh |
| 180 | configMap: |
| 181 | name: {{ include "common.fullname" . }}-mariadb-sh |
| 182 | - name: docker-entrypoint-initdb-d-sql |
| 183 | configMap: |
| 184 | name: {{ include "common.fullname" . }}-mariadb-sql |
Mahendra Raghuwanshi | 72b69c1 | 2019-04-04 10:43:25 +0000 | [diff] [blame] | 185 | {{- if .Values.global.migration.enabled }} |
| 186 | - name: backup-storage |
| 187 | persistentVolumeClaim: |
| 188 | claimName: {{ include "common.fullname" . }}-migration |
| 189 | {{- end }} |
| 190 | restartPolicy: Never |
| 191 | imagePullSecrets: |
| 192 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |