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 }}
114 - name: {{ include "common.name" . }}-inject-testlab-project
119 git clone -b {{ .Values.config.gerritBranch }} --single-branch {{ .Values.config.gerritProject }} /tmp/gerrit;
120 echo "Clone complete. Copying from /tmp/gerrit/volumes/mariadb/docker-entrypoint-initdb.d to /docker-entrypoint-initdb.d";
121 cp -rf /tmp/gerrit/volumes/mariadb/docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d;
122 chmod -R 755 /docker-entrypoint-initdb.d;
124 image: "{{ .Values.global.ubuntuInitRepository }}/{{ .Values.ubuntuInitImage }}"
125 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
127 - name: docker-entrypoint-initdb-d
128 mountPath: "/docker-entrypoint-initdb.d"
130 - name: {{ include "common.name" . }}
131 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
132 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
137 mysql() { /usr/bin/mysql -h ${DB_HOST} -P ${DB_PORT} "$@"; };
139 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 }};
140 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;
141 {{- if .Values.global.migration.enabled }}
142 mysql -vv --user=root --password=${MYSQL_ROOT_PASSWORD} < `ls -tr /var/data/mariadb/* | tail -1`;
148 name: {{ .Release.Name}}-so-db-secrets
149 key: mariadb.readwrite.host
153 name: {{ .Release.Name}}-so-db-secrets
154 key: mariadb.readwrite.port
155 - name: MYSQL_ROOT_PASSWORD
158 name: {{ template "common.fullname" . }}
159 key: db-root-password
161 - mountPath: /etc/localtime
164 - name: docker-entrypoint-initdb-d
165 mountPath: "/docker-entrypoint-initdb.d"
166 {{- if .Values.global.migration.enabled }}
167 - name: backup-storage
168 mountPath: /var/data/mariadb
171 {{ include "common.resources" . | indent 12 }}
172 {{- if .Values.nodeSelector }}
174 {{ toYaml .Values.nodeSelector | indent 10 }}
176 {{- if .Values.affinity }}
178 {{ toYaml .Values.affinity | indent 10 }}
184 - name: docker-entrypoint-initdb-d
186 {{- if .Values.global.migration.enabled }}
187 - name: backup-storage
188 persistentVolumeClaim:
189 claimName: {{ include "common.fullname" . }}-migration
193 - name: "{{ include "common.namespace" . }}-docker-registry-key"