diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml index 0210c3fbcd..472279563a 100644 --- a/mariadb/templates/statefulset.yaml +++ b/mariadb/templates/statefulset.yaml @@ -40,6 +40,22 @@ spec: {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} initContainers: {{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} +{{- if .Values.volume.chown_on_start }} + - name: mariadb-perms + image: {{ .Values.images.tags.mariadb }} + imagePullPolicy: {{ .Values.images.pull_policy }} + securityContext: + runAsUser: 0 +{{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + command: + - chown + - -R + - "mysql:mysql" + - /var/lib/mysql + volumeMounts: + - name: mysql-data + mountPath: /var/lib/mysql +{{- end }} containers: - name: mariadb image: {{ .Values.images.tags.mariadb }} diff --git a/mariadb/values.yaml b/mariadb/values.yaml index 896032e932..429e09b3f3 100644 --- a/mariadb/values.yaml +++ b/mariadb/values.yaml @@ -53,6 +53,7 @@ dependencies: force_bootstrap: false volume: + chown_on_start: true enabled: true class_name: general size: 5Gi