Skip to content

Commit d8b3959

Browse files
committed
[mariadb] run sidecars as a native sidecars
* Add an option to run all sidecar containers as a native sidecar. This option is enabled by default. Example configuration values: ```yaml global: mariadb: native_sidecar: enabled: true ```
1 parent 4291772 commit d8b3959

File tree

10 files changed

+118
-79
lines changed

10 files changed

+118
-79
lines changed

common/mariadb/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## v0.29.0 - 2025/10/28
4+
* Add an option to run all sidecar containers as a native sidecar.
5+
6+
This option is enabled by default.
7+
8+
Example configuration values:
9+
```yaml
10+
global:
11+
mariadb:
12+
native_sidecar:
13+
enabled: true
14+
```
15+
316
## v0.28.1 - 2025/10/27
417
* mysqld-exporter now collects data from mysql.user table
518

common/mariadb/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v2
33
description: A Helm chart for Kubernetes
44
name: mariadb
5-
version: 0.28.1
5+
version: 0.29.0
66
# scripts/docker-entyrpoint.sh should be updated when appVersion is updated
77
appVersion: 10.11.14
88
dependencies:

common/mariadb/templates/_helpers.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ helm.sh/chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
137137
Default pod labels for linkerd
138138
*/}}
139139
{{- define "mariadb.linkerdPodAnnotations" }}
140-
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) $.Values.linkerd.mariadb.enabled }}
140+
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) }}
141141
linkerd.io/inject: enabled
142-
{{- if $.Values.global.linkerd_use_native_sidecar }}
142+
{{- if or $.Values.global.linkerd_use_native_sidecar $.Values.global.mariadb.native_sidecar.enabled }}
143143
config.alpha.linkerd.io/proxy-enable-native-sidecar: "true"
144144
{{- end }}
145145
{{- end }}

common/mariadb/templates/backup-v2-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ spec:
2828
prometheus.io/scrape: "true"
2929
prometheus.io/targets: {{ required ".Values.alerts.prometheus missing" .Values.alerts.prometheus | quote }}
3030
{{- end }}
31-
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) $.Values.linkerd.backup.enabled }}
32-
linkerd.io/inject: enabled
31+
{{- if $.Values.linkerd.backup.enabled }}
32+
{{- include "mariadb.linkerdPodAnnotations" . | indent 8 }}
3333
{{- end }}
3434
spec:
3535
affinity:

common/mariadb/templates/backup-verify-deploy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ spec:
2626
prometheus.io/port: "8082"
2727
prometheus.io/targets: {{ required ".Values.alerts.prometheus missing" .Values.alerts.prometheus | quote }}
2828
{{- end }}
29-
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) $.Values.linkerd.backup.enabled }}
30-
linkerd.io/inject: enabled
29+
{{- if $.Values.linkerd.backup.enabled }}
30+
{{- include "mariadb.linkerdPodAnnotations" . | indent 8 }}
3131
{{- end }}
3232
spec:
3333
serviceAccountName: {{ .Values.name }}-db-backup-v2

common/mariadb/templates/cronjob-mariadb-maintenance.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ spec:
2222
{{- include "mariadb.labels" (list $ "version" "mariadb" "cronjob" "maintenance") | indent 12 }}
2323
annotations:
2424
kubectl.kubernetes.io/default-container: maintenance
25-
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) $.Values.linkerd.mariadb.enabled }}
26-
linkerd.io/inject: enabled
27-
{{- end }}
2825
checksum/configmap: {{ include (print $.Template.BasePath "/configmap-mariadb-maintenance.yaml") $ | sha256sum }}
26+
{{- if $.Values.linkerd.cronjob.enabled }}
27+
{{- include "mariadb.linkerdPodAnnotations" . | indent 12 }}
28+
{{- end }}
2929
spec:
3030
restartPolicy: {{ $.Values.job.maintenance.jobRestartPolicy | default "OnFailure" | quote }}
3131
securityContext:

common/mariadb/templates/deployment.yaml

Lines changed: 78 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ spec:
3030
prometheus.io/scrape: "true"
3131
prometheus.io/targets: {{ required ".Values.alerts.prometheus missing" .Values.alerts.prometheus | quote }}
3232
{{- end }}
33-
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) $.Values.linkerd.mariadb.enabled }}
34-
linkerd.io/inject: enabled
33+
{{- if $.Values.linkerd.mariadb.enabled }}
34+
{{- include "mariadb.linkerdPodAnnotations" . | indent 8 }}
3535
{{- end }}
3636
spec:
3737
affinity:
@@ -72,70 +72,14 @@ spec:
7272
readOnly: true
7373
- name: init-file-root-sql
7474
mountPath: /etc/mysql/init-file
75+
{{- if .Values.global.mariadb.native_sidecar.enabled }}
76+
{{- else }}
7577
containers:
76-
- name: mariadb
77-
image: {{ required ".Values.global.dockerHubMirrorAlternateRegion is missing" .Values.global.dockerHubMirrorAlternateRegion }}/{{ .Values.image }}
78-
imagePullPolicy: {{ default "IfNotPresent" .Values.imagePullPolicy | quote }}
79-
lifecycle:
80-
postStart:
81-
exec:
82-
command: ["sh", "-c", "while ! mariadb-admin ping --silent; do sleep 1; done; mariadb-upgrade"]
83-
env:
84-
- name: MYSQL_ROOT_PASSWORD
85-
valueFrom:
86-
secretKeyRef:
87-
name: mariadb-{{.Values.name}}
88-
key: root-password
89-
ports:
90-
- name: mariadb
91-
containerPort: 3306
92-
{{- if .Values.livenessProbe.enabled }}
93-
livenessProbe:
94-
exec:
95-
command: ["sh", "-c", "exec mariadb-admin status"]
96-
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
97-
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
98-
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
99-
successThreshold: {{ .Values.livenessProbe.successThreshold }}
100-
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
101-
{{- end }}
102-
{{- if .Values.readinessProbe.enabled }}
103-
readinessProbe:
104-
exec:
105-
command: ["sh", "-c", "exec mariadb-admin status"]
106-
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
107-
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
108-
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
109-
successThreshold: {{ .Values.readinessProbe.successThreshold }}
110-
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
111-
{{- end }}
112-
resources:
113-
{{ toYaml (required "missing .resources" .Values.resources) | indent 10 }}
114-
volumeMounts:
115-
- name: mariadb-socket
116-
mountPath: /run/mysqld
117-
{{- if .Values.persistence_claim.enabled }}
118-
- name: mariadb-persistent-storage
119-
mountPath: /var/lib/mysql
120-
readOnly: false
12178
{{- end }}
122-
- mountPath: /usr/local/bin/docker-entrypoint.sh
123-
subPath: docker-entrypoint.sh
124-
name: mariadb-entrypoint
125-
readOnly: true
126-
- mountPath: /etc/mysql/mariadb.conf.d/
127-
name: mariadb-etc
128-
- mountPath: /root/.my.cnf
129-
subPath: ".my.cnf"
130-
name: mariadb-client
131-
- name: initdb
132-
mountPath: /docker-entrypoint-initdb.d
133-
- name: mysql-users-secret-file
134-
mountPath: /etc/mysql/mysql-users-secret
135-
readOnly: true
136-
- name: init-file-root-sql
137-
mountPath: /etc/mysql/init-file
13879
- name: user-credential-updater
80+
{{- if .Values.global.mariadb.native_sidecar.enabled }}
81+
restartPolicy: Always
82+
{{- end }}
13983
image: "{{ required ".Values.global.registryAlternateRegion is missing" .Values.global.registryAlternateRegion }}/{{ .Values.credentialUpdater.image }}:{{ .Values.credentialUpdater.imageTag }}"
14084
imagePullPolicy: {{ default "IfNotPresent" .Values.imagePullPolicy | quote }}
14185
securityContext:
@@ -168,6 +112,9 @@ spec:
168112
name: initdb
169113
{{- if or .Values.backup_v2.enabled .Values.readiness.useSidecar }}
170114
- name: readiness
115+
{{- if .Values.global.mariadb.native_sidecar.enabled }}
116+
restartPolicy: Always
117+
{{- end }}
171118
image: "{{ required ".Values.global.registryAlternateRegion is missing" .Values.global.registryAlternateRegion }}/{{ .Values.readiness.image }}:{{ .Values.readiness.image_version }}"
172119
command:
173120
- pod_readiness
@@ -187,6 +134,9 @@ spec:
187134
{{- end }}
188135
{{- if .Values.metrics.enabled }}
189136
- name: metrics
137+
{{- if .Values.global.mariadb.native_sidecar.enabled }}
138+
restartPolicy: Always
139+
{{- end }}
190140
image: "{{ required ".Values.global.dockerHubMirrorAlternateRegion is missing" .Values.global.dockerHubMirrorAlternateRegion }}/{{ .Values.metrics.image }}:{{ .Values.metrics.image_version }}"
191141
imagePullPolicy: {{ default "IfNotPresent" .Values.imagePullPolicy | quote }}
192142
args:
@@ -225,6 +175,71 @@ spec:
225175
memory: {{ .Values.metrics.resources.requests.memory | quote }}
226176
{{- end }}
227177
{{- end }}
178+
{{- if .Values.global.mariadb.native_sidecar.enabled }}
179+
containers:
180+
{{- end }}
181+
- name: mariadb
182+
image: {{ required ".Values.global.dockerHubMirrorAlternateRegion is missing" .Values.global.dockerHubMirrorAlternateRegion }}/{{ .Values.image }}
183+
imagePullPolicy: {{ default "IfNotPresent" .Values.imagePullPolicy | quote }}
184+
lifecycle:
185+
postStart:
186+
exec:
187+
command: ["sh", "-c", "while ! mariadb-admin ping --silent; do sleep 1; done; mariadb-upgrade"]
188+
env:
189+
- name: MYSQL_ROOT_PASSWORD
190+
valueFrom:
191+
secretKeyRef:
192+
name: mariadb-{{.Values.name}}
193+
key: root-password
194+
ports:
195+
- name: mariadb
196+
containerPort: 3306
197+
{{- if .Values.livenessProbe.enabled }}
198+
livenessProbe:
199+
exec:
200+
command: ["sh", "-c", "exec mariadb-admin status"]
201+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
202+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
203+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
204+
successThreshold: {{ .Values.livenessProbe.successThreshold }}
205+
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
206+
{{- end }}
207+
{{- if .Values.readinessProbe.enabled }}
208+
readinessProbe:
209+
exec:
210+
command: ["sh", "-c", "exec mariadb-admin status"]
211+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
212+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
213+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
214+
successThreshold: {{ .Values.readinessProbe.successThreshold }}
215+
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
216+
{{- end }}
217+
resources:
218+
{{ toYaml (required "missing .resources" .Values.resources) | indent 10 }}
219+
volumeMounts:
220+
- name: mariadb-socket
221+
mountPath: /run/mysqld
222+
{{- if .Values.persistence_claim.enabled }}
223+
- name: mariadb-persistent-storage
224+
mountPath: /var/lib/mysql
225+
readOnly: false
226+
{{- end }}
227+
- mountPath: /usr/local/bin/docker-entrypoint.sh
228+
subPath: docker-entrypoint.sh
229+
name: mariadb-entrypoint
230+
readOnly: true
231+
- mountPath: /etc/mysql/mariadb.conf.d/
232+
name: mariadb-etc
233+
- mountPath: /root/.my.cnf
234+
subPath: ".my.cnf"
235+
name: mariadb-client
236+
- name: initdb
237+
mountPath: /docker-entrypoint-initdb.d
238+
- name: mysql-users-secret-file
239+
mountPath: /etc/mysql/mysql-users-secret
240+
readOnly: true
241+
- name: init-file-root-sql
242+
mountPath: /etc/mysql/init-file
228243
priorityClassName: {{ .Values.priority_class | default "critical-infrastructure" | quote }}
229244
volumes:
230245
- name: mariadb-socket

common/mariadb/templates/rename-check-constraints-job.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ spec:
2222
{{- include "mariadb.labels" (list $ "version" "mariadb" "job" "rename-check-constraints") | indent 8 }}
2323
annotations:
2424
kubectl.kubernetes.io/default-container: rename-check-constraints
25-
{{- if and (and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested) $.Values.linkerd.mariadb.enabled }}
26-
linkerd.io/inject: enabled
27-
config.alpha.linkerd.io/proxy-enable-native-sidecar: "true"
25+
{{- if $.Values.linkerd.mariadb.enabled }}
26+
{{- include "mariadb.linkerdPodAnnotations" . | indent 8 }}
2827
{{- end }}
2928
spec:
3029
restartPolicy: {{ .Values.job.renameCheckConstraints.jobRestartPolicy | default "Never" | quote }}

common/mariadb/templates/sync-statefulset.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ spec:
2222
app.kubernetes.io/instance: {{ include "fullName" . }}-sync
2323
annotations:
2424
kubectl.kubernetes.io/default-container: "sync"
25+
{{- if $.Values.linkerd.sync.enabled }}
2526
{{- include "mariadb.linkerdPodAnnotations" . | indent 8 }}
27+
{{- end }}
2628
spec:
2729
affinity:
2830
nodeAffinity:

common/mariadb/values.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
---
12
# Default values for mariadb.
23
# This is a YAML-formatted file.
34
# Declare name/value pairs to be passed into your templates.
45
# name: value
6+
global:
7+
mariadb:
8+
native_sidecar:
9+
enabled: true
510

611
name: null
712
image: library/mariadb:10.11.14
@@ -289,12 +294,17 @@ vpa:
289294
set_main_container: false
290295
linkerd:
291296
mariadb:
292-
#linkerd annotation for the MariaDB pod (true/false)
297+
# linkerd annotation for the MariaDB pod (true/false)
293298
enabled: true
294299
backup:
295-
#linkerd annotation for the backup pod (true/false)
300+
# linkerd annotation for the backup pod (true/false)
301+
enabled: true
302+
cronjob:
303+
# linkerd annotation for the cronjob pods (true/false)
304+
enabled: true
305+
sync:
306+
# linkerd annotation for the go-maria-sync pod (true/false)
296307
enabled: true
297-
global: {}
298308

299309
tcp_keepalive:
300310
# Timeout, in seconds, with no activity until the first TCP keep-alive packet is sent. If set to 0, a system dependent default is used https://mariadb.com/kb/en/server-system-variables/#tcp_keepalive_time

0 commit comments

Comments
 (0)