mariadb

by HelmForge

Helm chartv3.0.0App 13.0.2Apache-2.0Verified publisher

MariaDB for Kubernetes with explicit standalone and replication modes

About this chart

MariaDB Helm Chart

Helm chart for deploying MariaDB on Kubernetes using the official mariadb Docker image. Supports standalone and GTID-based replication architectures.

Breaking Change in 3.0.0

Replica bootstrap now fails closed when a non-empty logical replica datadir has neither HelmForge bootstrap state nor MariaDB replication metadata. Healthy existing replicas are detected and continue normally. A trusted bootstrap that was interrupted on an older chart can be resumed once with replication.readReplicas.bootstrap.resumeUnmarkedDatadir: true; unknown PVCs must not use this escape hatch.

The new opt-in volumeSnapshot method creates a distinct replica StatefulSet and new snapshot-backed PVCs. Existing logical replica PVCs are retained for rollback only when retentionPolicy.whenDeleted: Retain is reconciled before the method switch; they are not migrated. Read the replica bootstrap migration guide before enabling the method on an existing release.

Breaking Change in 2.0.0

MariaDB now mounts /var/lib/mysql from the data volume subdirectory configured by persistence.subPath instead of the volume root. The default is mysql. This prevents ext4-backed PVCs from exposing the filesystem-created lost+found directory to MariaDB as a candidate database.

Existing installations whose data already lives at the volume root must set the legacy value during upgrade:

persistence:
  subPath: ""

Alternatively, migrate the existing volume-root data into the mysql subdirectory before upgrading.

Supported Architectures

ArchitectureDescription
standaloneSingle MariaDB instance with persistent storage (default)
replicationOne fixed source with asynchronous GTID-based read replicas

Features

  • Official MariaDB image from Docker Hub
  • Standalone and replication modes with explicit configuration
  • GTID-based replication using MariaDB-native GTID (MASTER_USE_GTID=slave_pos)
  • Physical replica bootstrap from an operator-provided, application-consistent CSI VolumeSnapshot
  • Configuration presets small, medium, large, oltp, read-heavy, analytics
  • Resource presets small, medium, large for easy right-sizing
  • Init scripts support via ConfigMap or inline values
  • TLS server-side encryption with optional client enforcement
  • Prometheus metrics via mysqld-exporter sidecar and ServiceMonitor
  • S3-compatible backup CronJob with mariadb-dump and minio/mc upload
  • NetworkPolicy for ingress traffic control
  • PodDisruptionBudget for availability during maintenance
  • Datadir subPath isolation to keep ext4 lost+found out of MariaDB logs
  • Password management auto-generated or from existing Secret
  • Dual-stack networking — IPv4/IPv6 service support across all 6 Service objects
  • External Secrets Operator — ExternalSecret for Vault, AWS Secrets Manager, and more

Installation

HTTPS Repository

helm repo add helmforge https://repo.helmforge.dev
helm repo update
helm install mariadb helmforge/mariadb

OCI Registry

helm install mariadb oci://ghcr.io/helmforgedev/helm/mariadb

Examples

The repository includes complete examples for standalone, replication, production replication, and legacy volume-root upgrades under examples/. The smallest architecture overrides are:

Architecture selection

# Standalone (default)
architecture: standalone

# Replication with 2 read replicas
architecture: replication
replication:
  readReplicas:
    replicaCount: 2

Replica Bootstrap

Read replicas use a GTID-aware logical dump by default. Large installations can opt into physical bootstrap from one application-consistent CSI VolumeSnapshot; the chart restores only new replica PVCs and requires the GTID captured at the exact snapshot point. The chart does not pause the source or create the snapshot.

See the replica bootstrap guide for prerequisites, upgrade impact, rollback, validation and failure recovery.

Main Values

KeyDefaultDescription
architecturestandaloneDeployment mode: standalone or replication
image.repositorymariadbMariaDB image
image.tag13.0.2MariaDB version
auth.rootPassword""Root password (auto-generated if empty)
auth.databaseappApplication database
auth.usernameappApplication user
auth.password""Application password (auto-generated if empty)
auth.replicationUsernamereplicatorReplication user
auth.existingSecret""Existing secret with passwords
config.presetnoneConfiguration preset
config.myCnf""Extra my.cnf content
persistence.subPathmysqlData volume subdirectory mounted as /var/lib/mysql; set "" for legacy volume-root installs
persistence.prepareDataDir.enabledfalseOpt-in root initContainer for storage drivers that do not honor fsGroup; incompatible with Pod Security restricted
standalone.resourcesPresetsmallDefault standalone resource requests and limits
standalone.persistence.size8GiStandalone PVC size
replication.source.resourcesPresetsmallDefault source resource requests and limits
replication.source.persistence.size20GiSource PVC size
replication.source.affinity{}Affinity for the source pod
replication.source.tolerations[]Tolerations for the source pod
replication.readReplicas.replicaCount2Number of read replicas
replication.readReplicas.bootstrap.methodlogicalReplica bootstrap method: logical or volumeSnapshot
replication.readReplicas.bootstrap.resumeUnmarkedDatadirfalseUnsafe one-time escape hatch for a trusted legacy partial logical bootstrap
replication.readReplicas.bootstrap.volumeSnapshot.name""Application-consistent source VolumeSnapshot used by new replica PVCs
replication.readReplicas.bootstrap.volumeSnapshot.gtid""MariaDB GTID captured at the exact snapshot point
replication.readReplicas.resourcesPresetsmallDefault replica resource requests and limits
replication.readReplicas.persistence.size20GiReplica PVC size
replication.readReplicas.affinity{}Affinity for the replica pods
replication.readReplicas.tolerations[]Tolerations for the replica pods
replication.binlog.formatROWBinlog format
service.typeClusterIPService type
service.port3306MariaDB port
metrics.enabledfalseEnable mysqld-exporter
tls.enabledfalseEnable server TLS
backup.enabledfalseEnable S3 backup CronJob
backup.schedule"0 3 * * *"Backup cron schedule
backup.s3.credentialsFromPodIdentityfalseUse EKS Pod Identity or IRSA instead of static S3 keys
backup.s3.region""AWS region required by workload identity
backup.serviceAccount.annotations{}Annotations for the dedicated backup identity
networkPolicy.enabledfalseEnable NetworkPolicy
pdb.enabledfalseEnable PodDisruptionBudget
service.ipFamilyPolicy~IP family policy (SingleStack, PreferDualStack, RequireDualStack)
service.ipFamilies[]IP families override (IPv4, IPv6)
extraObjects[]Extra Kubernetes manifests rendered with the release
externalSecrets.enabledfalseRender ExternalSecret resource
externalSecrets.apiVersionexternal-secrets.io/v1ExternalSecret API version
externalSecrets.refreshInterval1hRefresh interval
externalSecrets.secretStoreRef.name""SecretStore name (required when enabled)
externalSecrets.secretStoreRef.kindSecretStoreSecretStore kind
externalSecrets.data[]Remote key mappings

Dual-Stack Services

MariaDB 13.0.2 is the stable GA release of the 13.0 rolling line. It adds atomic CREATE OR REPLACE TABLE, single-table UPDATE ... RETURNING, InnoDB log archiving and new routine types. Back up databases and validate startup, replication, application compatibility and restore behavior before this major upgrade. mariadb-backup does not support the new log-archive format while innodb_log_archive=ON.

All 6 Service objects (client, metrics, source, source-metrics, replicas, replicas-metrics) carry the same ipFamilyPolicy and ipFamilies settings.

service:
  ipFamilyPolicy: PreferDualStack
  ipFamilies:
    - IPv4
    - IPv6

Datadir SubPath and lost+found

Kubernetes storage classes often format PVCs as ext4. ext4 creates lost+found at the filesystem root, and MariaDB scans every datadir subdirectory as a database. Mounting the PVC root at /var/lib/mysql can therefore produce this non-fatal but noisy log line:

Invalid (old?) table or database name 'lost+found'

The chart avoids that on new installs by mounting the mysql subdirectory as the datadir:

persistence:
  subPath: mysql

For existing installations with data at the PVC root, keep the legacy behavior:

persistence:
  subPath: ""

See docs/datadir-subpath.md for upgrade guidance.

By default, the chart does not render a root initContainer for persistence.subPath. It relies on podSecurityContext.fsGroup and fsGroupChangePolicy: OnRootMismatch, which keeps the default path compatible with Pod Security restricted.

Only enable persistence.prepareDataDir.enabled=true for storage drivers that do not honor fsGroup for subPath directories. That opt-in path runs as root with CHOWN and FOWNER and requires a namespace-level Pod Security exception.

External Secrets Operator (ESO)

auth.existingSecret is required alongside externalSecrets.enabled=true to prevent credential drift between the chart-managed Secret and the ExternalSecret.

auth:
  existingSecret: mariadb-credentials

externalSecrets:
  enabled: true
  secretStoreRef:
    name: vault-backend
    kind: ClusterSecretStore
  data:
    - secretKey: mariadb-root-password
      remoteRef:
        key: mariadb/credentials
        property: root-password
    - secretKey: mariadb-user-password
      remoteRef:
        key: mariadb/credentials
        property: user-password

Differences from MySQL Chart

This chart uses MariaDB-native features:

  • GTID replication uses MASTER_USE_GTID=slave_pos (MariaDB GTID is always enabled, no gtid_mode toggle)
  • Commands use mariadb, mariadb-admin, mariadb-dump (not mysql, mysqladmin, mysqldump)
  • Environment variables use MARIADB_* prefix (not MYSQL_*)
  • Replication uses CHANGE MASTER TO with MariaDB-specific options
  • No mysqlx protocol (MySQL-specific)

CI Scenarios

FileDescription
standalone.yamlBasic standalone mode
replication.yamlReplication with 2 replicas
initdb.yamlInit scripts with example table
existing-secret.yamlExternal secret reference
metrics.yamlMetrics sidecar enabled
replication-metrics.yamlReplication with metrics
config-preset.yamlOLTP config preset
resources-preset.yamlResource presets for replication
legacy-volume-root.yamlLegacy datadir mount for existing volume-root installs
tls.yamlTLS with existingSecret
tls-networkpolicy.yamlTLS + replication + NetworkPolicy
backup.yamlBackup with S3
dual-stack.yamlDual-stack service policy
external-secrets.yamlExternal Secrets Operator integration

Troubleshooting

Inspect the StatefulSet, MariaDB logs, and recent namespace events before changing probes or credentials:

kubectl get statefulset,pod,pvc,service -l app.kubernetes.io/instance=<release>
kubectl logs -l app.kubernetes.io/instance=<release> --all-containers --tail=200 --prefix
kubectl get events --sort-by=.lastTimestamp
  • If MariaDB reports lost+found as a database, preserve an existing volume-root installation with persistence.subPath: ""; see docs/datadir-subpath.md.
  • If a replica stays unready, verify that the source is writable, the replication credentials are stable, and both replication threads are running before enabling requireRunningReplication.
  • If the metrics sidecar cannot connect, verify the password Secret and keep tls.client.enabled aligned with the server TLS configuration.
  • If a NetworkPolicy is enabled, allow application traffic on service.port. Metrics scraping requires both metrics.enabled: true and networkPolicy.metrics.enabled: true; configure networkPolicy.metrics.extraFrom with the permitted scraper sources.

More Information

Security Scan: mariadb

FrameworkScore
MITRE + NSA + SOC289.898994%

Security posture acceptable.

Deploy mariadb with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mariadb on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmariadb is pinned at v3.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply