2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright (C) 2022/23 Nordix Foundation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 {{- if .Values.global.migration.enabled }}
21 name: {{ include "common.fullname" . }}-backup
22 namespace: {{ include "common.namespace" . }}
24 app: {{ include "common.name" . }}
25 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26 release: {{ include "common.release" . }}
27 heritage: {{ .Release.Service }}
29 "helm.sh/hook": pre-upgrade,pre-install
30 "helm.sh/hook-weight": "1"
31 "helm.sh/hook-delete-policy": before-hook-creation
37 app: {{ include "common.name" . }}
38 release: {{ include "common.release" . }}
39 name: {{ include "common.name" . }}
42 - name: {{ include "common.fullname" . }}
43 image: {{ include "repositoryGenerator.image.mariadb" . }}
44 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
47 value: {{ .Values.global.migration.dbHost }}
49 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-backup-creds" "key" "login") | indent 10 }}
51 value: "{{ .Values.global.migration.dbPort }}"
53 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-backup-creds" "key" "password") | indent 10 }}
58 {{- if include "common.onServiceMesh" . }}
59 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
60 mysqldump -vv --user=${DB_USER} --password=${DB_PASS} --host=${DB_HOST} --port=${DB_PORT} --databases --single-transaction --quick --lock-tables=false catalogdb requestdb nfvo cnfm > /var/data/mariadb/backup-`date +%s`.sql
62 - name: backup-storage
63 mountPath: /var/data/mariadb
64 {{ include "common.waitForJobContainer" . | indent 6 | trim }}
65 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
67 - name: backup-storage
68 persistentVolumeClaim:
69 claimName: {{ include "common.fullname" . }}-migration
70 {{- include "common.imagePullSecrets" . | nindent 6 }}
77 name: {{ include "common.fullname" . }}-config-job
78 namespace: {{ include "common.namespace" . }}
80 app: {{ include "common.name" . }}
81 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
82 release: {{ include "common.release" . }}
83 heritage: {{ .Release.Service }}
85 "helm.sh/hook": post-upgrade,post-rollback,post-install
86 "helm.sh/hook-weight": "0"
87 "helm.sh/hook-delete-policy": before-hook-creation
93 app: {{ include "common.name" . }}-job
94 release: {{ include "common.release" . }}
95 name: {{ include "common.name" . }}
97 initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
99 - name: {{ include "common.name" . }}-config
100 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
101 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
106 {{- if include "common.onServiceMesh" . }}
107 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
108 mysql() { /usr/bin/mysql -h ${DB_HOST} -P ${DB_PORT} "$@"; };
110 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 }};
111 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;
112 {{- if .Values.global.migration.enabled }}
113 mysql -vv --user=root --password=${MYSQL_ROOT_PASSWORD} < `ls -tr /var/data/mariadb/* | tail -1`;
117 value: {{ include "common.mariadbService" . }}
119 value: {{ include "common.mariadbPort" . | quote }}
120 - name: MYSQL_ROOT_PASSWORD
121 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-pass" "key" "password") | indent 10 }}
123 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "login") | indent 10 }}
125 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "password") | indent 10 }}
127 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "login") | indent 10 }}
128 - name: DB_ADMIN_PASSWORD
129 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "password") | indent 10 }}
130 - name: CAMUNDA_DB_USER
131 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "camunda-db-creds" "key" "login") | indent 10 }}
132 - name: CAMUNDA_DB_PASSWORD
133 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "camunda-db-creds" "key" "password") | indent 10 }}
134 - name: REQUEST_DB_USER
135 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "request-db-creds" "key" "login") | indent 10 }}
136 - name: REQUEST_DB_PASSWORD
137 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "request-db-creds" "key" "password") | indent 10 }}
138 - name: CATALOG_DB_USER
139 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "catalog-db-creds" "key" "login") | indent 10 }}
140 - name: CATALOG_DB_PASSWORD
141 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "catalog-db-creds" "key" "password") | indent 10 }}
143 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "nfvo-db-creds" "key" "login") | indent 10 }}
144 - name: NFVO_DB_PASSWORD
145 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "nfvo-db-creds" "key" "password") | indent 10 }}
147 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cnfm-db-creds" "key" "login") | indent 10 }}
148 - name: CNFM_DB_PASSWORD
149 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cnfm-db-creds" "key" "password") | indent 10 }}
151 - name: docker-entrypoint-initdb-d-sh
152 mountPath: "/docker-entrypoint-initdb.d"
153 - name: docker-entrypoint-initdb-d-sql
154 mountPath: "/docker-entrypoint-initdb.d/db-sql-scripts"
155 {{- if .Values.global.migration.enabled }}
156 - name: backup-storage
157 mountPath: /var/data/mariadb
159 resources: {{ include "common.resources" . | nindent 10 }}
160 {{ include "common.waitForJobContainer" . | indent 6 | trim }}
161 {{- if .Values.nodeSelector }}
163 {{ toYaml .Values.nodeSelector | indent 10 }}
165 {{- if .Values.affinity }}
167 {{ toYaml .Values.affinity | indent 10 }}
169 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
171 - name: docker-entrypoint-initdb-d-sh
173 name: {{ include "common.fullname" . }}-mariadb-sh
174 - name: docker-entrypoint-initdb-d-sql
176 name: {{ include "common.fullname" . }}-mariadb-sql
177 {{- if .Values.global.migration.enabled }}
178 - name: backup-storage
179 persistentVolumeClaim:
180 claimName: {{ include "common.fullname" . }}-migration
183 {{- include "common.imagePullSecrets" . | nindent 6 }}