2 # Copyright © 2017 Amdocs, Bell Canada
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 {{- if .Values.global.migration.enabled }}
20 name: {{ include "common.fullname" . }}-backup
21 namespace: {{ include "common.namespace" . }}
23 app: {{ include "common.name" . }}
24 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25 release: {{ include "common.release" . }}
26 heritage: {{ .Release.Service }}
28 "helm.sh/hook": pre-upgrade,pre-install
29 "helm.sh/hook-weight": "1"
30 "helm.sh/hook-delete-policy": before-hook-creation
36 app: {{ include "common.name" . }}
37 release: {{ include "common.release" . }}
38 name: {{ include "common.name" . }}
41 - name: {{ include "common.fullname" . }}
42 image: {{ include "repositoryGenerator.image.mariadb" . }}
43 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
46 value: {{ .Values.global.migration.dbHost }}
48 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-backup-creds" "key" "login") | indent 10 }}
50 value: "{{ .Values.global.migration.dbPort }}"
52 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-backup-creds" "key" "password") | indent 10 }}
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
61 - mountPath: /etc/localtime
64 - name: backup-storage
65 mountPath: /var/data/mariadb
66 {{ include "common.waitForJobContainer" . | indent 6 | trim }}
67 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
72 - name: backup-storage
73 persistentVolumeClaim:
74 claimName: {{ include "common.fullname" . }}-migration
76 - name: "{{ include "common.namespace" . }}-docker-registry-key"
83 name: {{ include "common.fullname" . }}-config-job
84 namespace: {{ include "common.namespace" . }}
86 app: {{ include "common.name" . }}
87 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
88 release: {{ include "common.release" . }}
89 heritage: {{ .Release.Service }}
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
99 app: {{ include "common.name" . }}-job
100 release: {{ include "common.release" . }}
101 name: {{ include "common.name" . }}
103 initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
105 - name: {{ include "common.name" . }}-config
106 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
107 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
112 {{- if include "common.onServiceMesh" . }}
113 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
114 mysql() { /usr/bin/mysql -h ${DB_HOST} -P ${DB_PORT} "$@"; };
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`;
123 value: {{ include "common.mariadbService" . }}
125 value: {{ include "common.mariadbPort" . | quote }}
126 - name: MYSQL_ROOT_PASSWORD
127 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-pass" "key" "password") | indent 10 }}
129 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "login") | indent 10 }}
131 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "password") | indent 10 }}
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 }}
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 }}
153 - mountPath: /etc/localtime
156 - name: docker-entrypoint-initdb-d-sh
157 mountPath: "/docker-entrypoint-initdb.d"
158 - name: docker-entrypoint-initdb-d-sql
159 mountPath: "/docker-entrypoint-initdb.d/db-sql-scripts"
160 {{- if .Values.global.migration.enabled }}
161 - name: backup-storage
162 mountPath: /var/data/mariadb
165 {{ include "common.resources" . | indent 12 }}
166 {{ include "common.waitForJobContainer" . | indent 6 | trim }}
167 {{- if .Values.nodeSelector }}
169 {{ toYaml .Values.nodeSelector | indent 10 }}
171 {{- if .Values.affinity }}
173 {{ toYaml .Values.affinity | indent 10 }}
179 - name: docker-entrypoint-initdb-d-sh
181 name: {{ include "common.fullname" . }}-mariadb-sh
182 - name: docker-entrypoint-initdb-d-sql
184 name: {{ include "common.fullname" . }}-mariadb-sql
185 {{- if .Values.global.migration.enabled }}
186 - name: backup-storage
187 persistentVolumeClaim:
188 claimName: {{ include "common.fullname" . }}-migration
192 - name: "{{ include "common.namespace" . }}-docker-registry-key"