1 # Copyright © 2017 Amdocs, Bell Canada
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 {{- if .Values.global.migration.enabled }}
18 name: {{ include "common.fullname" . }}-backup
19 namespace: {{ include "common.namespace" . }}
21 app: {{ include "common.name" . }}
22 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23 release: {{ .Release.Name }}
24 heritage: {{ .Release.Service }}
26 "helm.sh/hook": pre-upgrade,pre-install
27 "helm.sh/hook-weight": "1"
28 "helm.sh/hook-delete-policy": before-hook-creation
34 app: {{ include "common.name" . }}
35 release: {{ .Release.Name }}
36 name: {{ include "common.name" . }}
39 - name: {{ include "common.fullname" . }}
40 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
41 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
44 value: {{ .Values.global.migration.dbHost }}
46 value: {{ .Values.global.migration.dbUser }}
48 value: "{{ .Values.global.migration.dbPort }}"
52 name: {{ template "common.fullname" . }}-migration
53 key: db-root-password-backup
57 - mysqldump -vv --user=${DB_USER} --password=${DB_PASS} --host=${DB_HOST} --port=${DB_PORT} --databases --single-transaction --quick --lock-tables=false catalogdb requestdb > /var/data/mariadb/backup-`date +%s`.sql
59 - mountPath: /etc/localtime
62 - name: backup-storage
63 mountPath: /var/data/mariadb
68 - name: backup-storage
69 persistentVolumeClaim:
70 claimName: {{ include "common.fullname" . }}-migration
72 - name: "{{ include "common.namespace" . }}-docker-registry-key"
79 name: {{ include "common.fullname" . }}-config-job
80 namespace: {{ include "common.namespace" . }}
82 app: {{ include "common.name" . }}
83 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
84 release: {{ .Release.Name }}
85 heritage: {{ .Release.Service }}
87 "helm.sh/hook": post-upgrade,post-rollback,post-install
88 "helm.sh/hook-weight": "0"
89 "helm.sh/hook-delete-policy": before-hook-creation
95 app: {{ include "common.name" . }}-job
96 release: {{ .Release.Name }}
97 name: {{ include "common.name" . }}
100 - name: {{ include "common.name" . }}-readiness
105 - {{ .Values.global.mariadbGalera.nameOverride }}
111 fieldPath: metadata.namespace
112 image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
113 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
115 - name: {{ include "common.name" . }}
116 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
117 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
122 mysql() { /usr/bin/mysql -h ${DB_HOST} -P ${DB_PORT} "$@"; };
124 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 }};
125 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;
126 {{- if .Values.global.migration.enabled }}
127 mysql -vv --user=root --password=${MYSQL_ROOT_PASSWORD} < `ls -tr /var/data/mariadb/* | tail -1`;
133 name: {{ .Release.Name}}-so-db-secrets
134 key: mariadb.readwrite.host
138 name: {{ .Release.Name}}-so-db-secrets
139 key: mariadb.readwrite.port
140 - name: MYSQL_ROOT_PASSWORD
143 name: {{ template "common.fullname" . }}
144 key: db-root-password
146 - mountPath: /etc/localtime
149 - name: docker-entrypoint-initdb-d-sh
150 mountPath: "/docker-entrypoint-initdb.d"
151 - name: docker-entrypoint-initdb-d-sql
152 mountPath: "/docker-entrypoint-initdb.d/db-sql-scripts"
153 {{- if .Values.global.migration.enabled }}
154 - name: backup-storage
155 mountPath: /var/data/mariadb
158 {{ include "common.resources" . | indent 12 }}
159 {{- if .Values.nodeSelector }}
161 {{ toYaml .Values.nodeSelector | indent 10 }}
163 {{- if .Values.affinity }}
165 {{ toYaml .Values.affinity | indent 10 }}
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
184 - name: "{{ include "common.namespace" . }}-docker-registry-key"