2 # Copyright © 2018 Amdocs, Bell Canada
3 # Copyright © 2019 Samsung Electronics
4 # Copyright © 2019-2020 Orange
5 # Copyright © 2020 Bitnami
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
22 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
24 podManagementPolicy: {{ .Values.podManagementPolicy }}
25 replicas: {{ .Values.replicaCount }}
26 selector: {{- include "common.selectors" . | nindent 4 }}
27 serviceName: {{ include "common.servicename" . }}-headless
29 type: {{ .Values.updateStrategy.type }}
30 {{- if (eq "Recreate" .Values.updateStrategy.type) }}
34 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
36 {{ include "common.podSecurityContext" . | indent 6 | trim }}
38 # we shouldn't need this but for unknown reason, it's fsGroup is not
40 - name: fix-permission
46 chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /data
47 chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /bootstrap/
48 chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /tmp/
49 {{- if .Values.mariadbConfiguration }}
50 cp /config/my.cnf /actual/my.cnf
51 chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /actual
53 image: {{ include "repositoryGenerator.image.busybox" . }}
54 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
60 - name: mariadb-tmp-folder
62 - name: {{ include "common.fullname" . }}
64 {{- if .Values.mariadbConfiguration }}
65 - name: mariadb-galera-starting-config
66 mountPath: /config/my.cnf
68 - name: mariadb-galera-actual-config
72 - name: {{ include "common.name" . }}
73 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
74 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy | quote}}
79 {{- if (not (empty (.Values.galera.bootstrap.bootstrapFromNode | quote)))}}
80 {{- $fullname := include "common.names.fullname" . }}
81 {{- $bootstrapFromNode := int .Values.galera.bootstrap.bootstrapFromNode }}
82 # Bootstrap from the indicated node
83 NODE_ID="${MY_POD_NAME#"{{ $fullname }}-"}"
84 if [[ "$NODE_ID" -eq "{{ $bootstrapFromNode }}" ]]; then
85 export MARIADB_GALERA_CLUSTER_BOOTSTRAP=yes
86 export MARIADB_GALERA_FORCE_SAFETOBOOTSTRAP={{ ternary "yes" "no" .Values.galera.bootstrap.forceSafeToBootstrap }}
89 exec /opt/bitnami/scripts/mariadb-galera/entrypoint.sh /opt/bitnami/scripts/mariadb-galera/run.sh
94 fieldPath: metadata.name
96 value: {{ ternary "true" "false" .Values.debug | quote }}
97 - name: MARIADB_INIT_SLEEP_TIME
98 value: {{ .Values.init_sleep_time | quote }}
99 - name: MARIADB_GALERA_CLUSTER_NAME
100 value: {{ .Values.galera.name | quote }}
101 - name: MARIADB_GALERA_CLUSTER_ADDRESS
102 value: "gcomm://{{ template "common.name" . }}-headless.{{ include "common.namespace" . }}.svc.{{ .Values.global.clusterDomain }}"
103 # Bitnami init script don't behave well in dual stack env.
104 # set it here as long as https://github.com/bitnami/charts/issues/4077 is not solved.
105 - name: MARIADB_GALERA_NODE_ADDRESS
108 fieldPath: status.podIP
109 - name: MARIADB_ROOT_USER
110 value: {{ .Values.rootUser.user | quote }}
111 - name: MARIADB_ROOT_PASSWORD
112 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 14 }}
114 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.userCredentialsUID" .) "key" "login") | indent 14 }}
115 - name: MARIADB_PASSWORD
116 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.userCredentialsUID" .) "key" "password") | indent 14 }}
117 - name: MARIADB_DATABASE
118 value: {{ .Values.db.name | quote }}
119 - name: MARIADB_GALERA_MARIABACKUP_USER
120 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.backupCredentialsUID" .) "key" "login") | indent 14 }}
121 - name: MARIADB_GALERA_MARIABACKUP_PASSWORD
122 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.backupCredentialsUID" .) "key" "password") | indent 14 }}
123 {{- if .Values.extraFlags }}
124 - name: MARIADB_EXTRA_FLAGS
125 value: {{ .Values.extraFlags | quote }}
127 ports: {{ include "common.containerPorts" . | nindent 12 }}
128 {{- if .Values.livenessProbe.enabled }}
135 exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD
136 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
137 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
138 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
139 successThreshold: {{ .Values.livenessProbe.successThreshold }}
140 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
142 {{- if .Values.readinessProbe.enabled }}
149 exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD
150 initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
151 periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
152 timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
153 successThreshold: {{ .Values.readinessProbe.successThreshold }}
154 failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
156 {{- if .Values.startupProbe.enabled }}
163 exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD
164 initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
165 periodSeconds: {{ .Values.startupProbe.periodSeconds }}
166 timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
167 successThreshold: {{ .Values.startupProbe.successThreshold }}
168 failureThreshold: {{ .Values.startupProbe.failureThreshold }}
170 resources: {{ include "common.resources" . | nindent 12 }}
172 - name: previous-boot
173 mountPath: /opt/bitnami/mariadb/.bootstrap
174 - name: {{ include "common.fullname" . }}
175 mountPath: /bitnami/mariadb
176 - name: mariadb-tmp-folder
177 mountPath: /opt/bitnami/mariadb/tmp
178 {{- if .Values.mariadbConfiguration }}
179 - name: mariadb-galera-actual-config
180 mountPath: /opt/bitnami/mariadb/conf
182 {{- if default false .Values.global.metrics.enabled }}
183 - name: {{ include "common.name" . }}-metrics
184 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }}
185 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}}
187 - name: MARIADB_METRICS_EXTRA_FLAGS
188 value: {{ default "" (join " " .Values.metrics.extraFlags) | quote }}
189 - name: MARIADB_ROOT_USER
190 value: {{ .Values.rootUser.user | quote }}
191 - name: MARIADB_ROOT_PASSWORD
192 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 14}}
197 DATA_SOURCE_NAME="$MARIADB_ROOT_USER:$MARIADB_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter $MARIADB_METRICS_EXTRA_FLAGS
205 initialDelaySeconds: 30
211 initialDelaySeconds: 5
213 {{ include "common.containerSecurityContext" . | indent 10 | trim }}
214 resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
217 - name: {{ include "common.namespace" . }}-docker-registry-key
218 {{- if .Values.schedulerName }}
219 schedulerName: {{ .Values.schedulerName | quote }}
221 {{- if .Values.priorityClassName }}
222 priorityClassName: {{ .Values.priorityClassName }}
224 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
225 {{- if .Values.affinity }}
226 affinity: {{- include "common.tplValue" ( dict "value" .Values.affinity "context" $) | nindent 8 }}
229 podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "context" $) | nindent 10 }}
230 podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "context" $) | nindent 10 }}
231 nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
233 {{- if .Values.nodeSelector }}
234 nodeSelector: {{- include "common.tplValue" ( dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
236 {{- if .Values.tolerations }}
237 tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" .) | nindent 8 }}
240 - name: previous-boot
242 - name: mariadb-tmp-folder
244 {{- if .Values.mariadbConfiguration }}
245 - name: mariadb-galera-actual-config
247 - name: mariadb-galera-starting-config
249 name: {{ printf "%s-configuration" (include "common.fullname" .) }}
251 {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
252 - name: {{ include "common.fullname" . }}
253 persistentVolumeClaim:
254 claimName: {{ .Values.persistence.existingClaim }}
255 {{- else if not .Values.persistence.enabled }}
256 - name: {{ include "common.fullname" . }}
258 {{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
259 volumeClaimTemplates:
260 - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "data" "persistenceInfos" .Values.persistence) | indent 6 | trim }}