blob: c347bef065c99a6c89dbc792bf9d64b3bb13759e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
{{/*
# Copyright © 2022 Nordix Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Chart.Name }}
namespace: default
labels:
app.kubernetes.io/name: {{ .Chart.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: Helm
spec:
podManagementPolicy: {{ .Values.podManagementPolicy }}
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ .Chart.Name }}
serviceName: {{ .Chart.Name }}-headless
updateStrategy:
type: {{ .Values.updateStrategy.type }}
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
rollingUpdate: null
{{- end }}
template:
metadata:
annotations:
traffic.sidecar.istio.io/excludeInboundPorts: 4444,4567,4568
traffic.sidecar.istio.io/excludeOutboundPorts: 4444,4567,4568
traffic.sidecar.istio.io/includeInboundPorts: '*'
labels:
app.kubernetes.io/name: {{ .Chart.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: Helm
name: {{ .Chart.Name }}
spec:
securityContext:
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
initContainers:
# we shouldn't need this but for unknown reason, it's fsGroup is not
# applied
- name: fix-permission
command:
- /bin/sh
args:
- -c
- |
chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /data
chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /bootstrap/
chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /tmp/
{{- if .Values.mariadbConfiguration }}
cp /config/my.cnf /actual/my.cnf
chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /actual
{{- end }}
image: docker.io/library/busybox:1.34.1
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
securityContext:
runAsUser: 0
volumeMounts:
- name: previous-boot
mountPath: /bootstrap
- name: mariadb-tmp-folder
mountPath: /tmp
- name: {{ .Chart.Name }}
mountPath: /data
{{- if .Values.mariadbConfiguration }}
- name: mariadb-galera-starting-config
mountPath: /config/my.cnf
subPath: my.cnf
- name: mariadb-galera-actual-config
mountPath: /actual
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.image }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy | quote}}
command:
- bash
- -ec
- |
{{- if (not (empty (.Values.galera.bootstrap.bootstrapFromNode | quote)))}}
{{- $fullname := "mariadb-galera" }}
{{- $bootstrapFromNode := int .Values.galera.bootstrap.bootstrapFromNode }}
# Bootstrap from the indicated node
NODE_ID="${MY_POD_NAME#"{{ $fullname }}-"}"
if [[ "$NODE_ID" -eq "{{ $bootstrapFromNode }}" ]]; then
export MARIADB_GALERA_CLUSTER_BOOTSTRAP=yes
export MARIADB_GALERA_FORCE_SAFETOBOOTSTRAP={{ ternary "yes" "no" .Values.galera.bootstrap.forceSafeToBootstrap }}
fi
{{- end }}
exec /opt/bitnami/scripts/mariadb-galera/entrypoint.sh /opt/bitnami/scripts/mariadb-galera/run.sh
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.debug | quote }}
- name: MARIADB_INIT_SLEEP_TIME
value: {{ .Values.init_sleep_time | quote }}
- name: MARIADB_GALERA_CLUSTER_NAME
value: {{ .Values.galera.name | quote }}
- name: MARIADB_GALERA_CLUSTER_ADDRESS
value: "gcomm://{{ .Chart.Name }}-headless.default.svc.{{ .Values.global.clusterDomain }}"
# Bitnami init script don't behave well in dual stack env.
# set it here as long as https://github.com/bitnami/charts/issues/4077 is not solved.
- name: MARIADB_GALERA_NODE_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MARIADB_ROOT_USER
value: {{ .Values.rootUser.user | quote }}
- name: MARIADB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-galera-db-root-password
key: password
- name: MARIADB_USER
valueFrom:
secretKeyRef:
name: mariadb-galera-db-user-credentials
key: login
- name: MARIADB_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-galera-db-user-credentials
key: password
- name: MARIADB_DATABASE
value: {{ .Values.db.name | quote }}
- name: MARIADB_GALERA_MARIABACKUP_USER
valueFrom:
secretKeyRef:
name: mariadb-galera-db-backup-credentials
key: login
- name: MARIADB_GALERA_MARIABACKUP_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-galera-db-backup-credentials
key: password
{{- if .Values.extraFlags }}
- name: MARIADB_EXTRA_FLAGS
value: {{ .Values.extraFlags | quote }}
{{- end }}
ports:
- containerPort: 3306
name: tcp-mysql
- containerPort: 4567
name: tcp-galera
- containerPort: 4568
name: tcp-ist
- containerPort: 4444
name: tcp-sst
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
exec:
command:
- sh
- -ec
- |
exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
exec:
command:
- sh
- -ec
- |
exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.startupProbe.enabled }}
startupProbe:
exec:
command:
- sh
- -ec
- |
exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.startupProbe.successThreshold }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
{{- end }}
resources:
{{ toYaml .Values.resources.small | indent 12 }}
volumeMounts:
- name: previous-boot
mountPath: /opt/bitnami/mariadb/.bootstrap
- name: {{ .Chart.Name }}
mountPath: /bitnami/mariadb
- name: mariadb-tmp-folder
mountPath: /opt/bitnami/mariadb/tmp
{{- if .Values.mariadbConfiguration }}
- name: mariadb-galera-actual-config
mountPath: /opt/bitnami/mariadb/conf
{{- end }}
imagePullSecrets:
- name: default-docker-registry-key
{{- if .Values.schedulerName }}
schedulerName: {{ .Values.schedulerName | quote }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
serviceAccountName: mariadb-galera-read
affinity:
podAffinity: {}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ .Chart.Name }}
namespaces:
- default
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity: {}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 10 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 10 }}
{{- end }}
volumes:
- name: previous-boot
emptyDir: {}
- name: mariadb-tmp-folder
emptyDir: {}
{{- if .Values.mariadbConfiguration }}
- name: mariadb-galera-actual-config
emptyDir: {}
- name: mariadb-galera-starting-config
configMap:
name: {{ .Chart.Name }}-configuration
{{- end }}
{{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
- name: {{ .Chart.Name }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim }}
{{- else if not .Values.persistence.enabled }}
- name: {{ .Chart.Name }}
emptyDir: {}
{{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
- metadata:
name: {{ .Chart.Name }}
namespace: default
labels:
app.kubernetes.io/name: {{ .Chart.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: Helm
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
storageClassName: mariadb-galera-data
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}
|