mysql

by HelmForge

Helm chartv2.4.2App 26.10.0Apache-2.0Verified publisher

MySQL for Kubernetes with explicit standalone and replication modes

About this chart

MySQL

MySQL for Kubernetes with explicit standalone and replication modes, documented bootstrap behavior, optional init scripts, optional metrics, TLS hardening, External Secrets Operator integration, and production-oriented controls.

Install

HTTPS repository

helm repo add helmforge https://repo.helmforge.dev
helm repo update
helm install mysql helmforge/mysql -f values.yaml

OCI registry

helm install mysql oci://ghcr.io/helmforgedev/helm/mysql -f values.yaml

Supported architectures

ArchitectureWhen to useDocument
standalonedevelopment, simpler production environments, or workloads where one writable MySQL instance is acceptabledocs/standalone.md
replicationone writable source plus asynchronous read replicas for read traffic and horizontal read scalingdocs/replication.md

What this chart covers

  • explicit architecture selection through architecture
  • MySQL on the official mysql image
  • generated or externally-managed passwords through existingSecret
  • application database and application user bootstrap on first initialization
  • optional extra init scripts
  • fixed-source asynchronous replication for read replicas
  • role-aware readiness checks for source and replicas in replication mode
  • optional metrics through mysqld-exporter
  • optional ServiceMonitor
  • built-in S3 backup CronJob using mysqldump --all-databases
  • dedicated metrics Services separated from client traffic
  • topology-specific Services for client traffic, source traffic, and read replicas
  • dual-stack Service options through service.ipFamilyPolicy and service.ipFamilies
  • External Secrets Operator v1 integration for auth, TLS, and backup Secrets
  • optional NetworkPolicy egress rules
  • optional TLS private-key permission normalization before MySQL startup
  • ServiceAccount token automount control
  • optional extraManifests for small companion resources and self-contained CI fixtures

How to choose the architecture

  • use standalone when operational simplicity matters more than read scaling
  • use replication when you need separate write and read endpoints, but you are not asking the chart to solve automatic failover

Recommended reading before installation:

  • Standalone
  • Replication
  • Replication Operations
  • Backup and Restore
  • Secret Rotation
  • Configuration Profiles
  • Production Hardening

Upgrade to MySQL 26.7.0

MySQL 26.7.0 is the first calendar-versioned Innovation release after the 9.7 LTS line. Both tracks are production-grade, but Innovation releases require a faster upgrade cadence. Back up and restore-test all databases, review removed or deprecated settings, and validate application/connector compatibility before upgrading existing PVCs. The backup client image is kept aligned with the server image.

Official product references

Operational direction

  • for production needing automatic failover, use an operator or another HA-specific solution instead of stretching this chart beyond its scope
  • replication in this chart means one fixed source with asynchronous read replicas
  • built-in logical backup to S3 is available for standalone and replication topologies

Read traffic model

In replication mode, the chart exposes separate Services for different traffic patterns:

  • the base client Service for general in-cluster access
  • a dedicated source Service for write traffic
  • a dedicated replicas Service for read-only traffic

The replicas Service is the endpoint to use for horizontal read scaling when an application or service can work against asynchronous read-only replicas.

Important limits:

  • Kubernetes Service balancing distributes connections across available replicas, but it is not a MySQL-aware query router
  • replica reads may lag behind the source because replication is asynchronous
  • workloads that require immediate read-after-write consistency should stay on the source endpoint

Quick start

Minimal standalone example:

architecture: standalone

auth:
  existingSecret: mysql-auth

standalone:
  persistence:
    enabled: true
    size: 20Gi

Replication example:

architecture: replication

auth:
  existingSecret: mysql-auth

replication:
  source:
    persistence:
      enabled: true
      size: 50Gi
  readReplicas:
    replicaCount: 2
    persistence:
      enabled: true
      size: 50Gi

metrics:
  enabled: true
  serviceMonitor:
    enabled: true

Best practices

Security

  • prefer auth.existingSecret in production
  • use externalSecrets.auth.enabled=true when credentials are sourced from an external secret store
  • keep client access internal unless there is a strong reason to expose MySQL outside the cluster network
  • enable tls.enabled=true with an externally-managed certificate secret when clients must use encrypted TCP connections
  • enable tls.volumePermissions.enabled=true when projected TLS Secret modes or ownership are not compatible with the non-root MySQL process
  • use tls.requireSecureTransport=true only when your clients and replication flows are ready to use TLS
  • use networkPolicy.enabled=true or external platform controls when possible
  • use networkPolicy.egress.enabled=true when the CNI enforces egress and explicitly allow DNS, same-namespace MySQL traffic, and any required HTTPS destinations
  • keep serviceAccount.automountServiceAccountToken=false unless an added sidecar or extension needs Kubernetes API access
  • if metrics are scraped through Prometheus, pair networkPolicy.enabled=true with networkPolicy.metrics.enabled=true
  • rotate passwords through secret management workflows instead of editing values inline

Replication and availability

  • treat replication as read scaling and operational recovery help, not full HA
  • place source and replicas across different nodes or zones when the cluster supports it
  • use pdb.enabled=true when running multiple replicas and planning maintenance windows
  • review the default replication PDB and placement behavior before overriding them globally
  • consider replication.readReplicas.probes.requireRunningReplication=true for environments where replica readiness should confirm replication threads are healthy
  • keep startupProbe conservative for MySQL, especially on larger volumes and replica catch-up paths

Initialization

  • use initdb.scripts for deterministic first-boot SQL or shell customization
  • use initdb.existingConfigMap when scripts are already managed elsewhere
  • remember that docker-entrypoint-initdb.d runs only during first initialization of a fresh data directory

Observability

  • enable metrics.enabled=true in monitored environments
  • enable metrics.serviceMonitor.enabled=true when Prometheus Operator is available
  • metrics are exposed through dedicated metrics Services, not through the client database Services
  • monitor connection count, replica lag, disk growth, and binary log retention

Configuration UX

  • use config.preset for a small set of opinionated MySQL defaults
  • use workload-oriented presets such as oltp, read-heavy, or analytics when the generic size presets are too vague
  • keep config.myCnf for raw overrides when the preset is not enough
  • keep auth.database, auth.username, and auth.replicationUsername as plain values; existingSecret is intentionally limited to sensitive runtime data

Production notes

  • use auth.existingSecret instead of inline passwords
  • alternatively use externalSecrets.auth.enabled=true with external-secrets.io/v1 and a preconfigured SecretStore or ClusterSecretStore
  • use tls.existingSecret for server certificates instead of trying to inline PEM material in values
  • use externalSecrets.tls.enabled=true when the TLS Secret should be reconciled by External Secrets Operator
  • use externalSecrets.backup.enabled=true for S3 credentials when the backup Secret should be reconciled by External Secrets Operator
  • keep persistence enabled for every stateful topology
  • set both whenDeleted and whenScaled to Retain under standalone.persistence.retentionPolicy, replication.source.persistence.retentionPolicy, or replication.readReplicas.persistence.retentionPolicy when uninstall or scale-down must keep the PVCs. Empty fields use the cluster default.
  • define node placement rules for replication, especially when the cluster spans multiple nodes or zones
  • use the client or source Service only for writes
  • use the replicas Service only for read traffic
  • use the replicas Service when you need horizontal scale for read-only workloads
  • when enabling TLS, plan certificate rotation as a rollout event because mounted secrets are not hot-reloaded by mysqld
  • built-in backup dumps all MySQL databases from the writable source endpoint and uploads the compressed archive to S3-compatible storage
  • treat restore validation, retention policy, and failover as operational workflows that still require explicit runbooks
  • review the architecture guides before promoting replication to production
  • start from examples/production.yaml for a complete production-oriented values file

Kubernetes 1.26 disables the StatefulSetAutoDeletePVC feature gate by default. On Kubernetes 1.26, enable the gate on both the API server and controller manager before relying on a Delete policy; otherwise the API server can omit the StatefulSet retention field. Kubernetes 1.27 and later enable the feature by default.

Operational documents:

  • Replication Operations
  • Backup and Restore
  • Secret Rotation
  • Configuration Profiles
  • Production Hardening

Main values

ParameterDescriptionDefault
architecturestandalone or replicationstandalone
image.repositoryMySQL image repositorydocker.io/library/mysql
image.tagMySQL image tag26.10.0
auth.databaseApp database created at bootstrapapp
auth.usernameApp user created at bootstrapapp
auth.existingSecretExisting secret for passwords""
auth.replicationUsernameReplication usernamereplicator
config.presetOptional MySQL config presetnone
standalone.resourcesPresetStandalone resource presetnone
replication.source.resourcesPresetSource resource presetnone
replication.readReplicas.resourcesPresetReplica resource presetnone
metrics.resourcesPresetExporter resource presetnone
initdb.existingConfigMapExternal ConfigMap for extra init scripts""
networkPolicy.enabledEnable NetworkPolicyfalse
networkPolicy.metrics.enabledAllow metrics scraping through NetworkPolicyfalse
networkPolicy.egress.enabledAdd egress policy rulesfalse
networkPolicy.egress.allowDNSAllow DNS egresstrue
networkPolicy.egress.allowSameNamespaceMySQLAllow same-namespace MySQL egresstrue
networkPolicy.egress.allowHTTPSAllow TCP/443 egressfalse
tls.enabledEnable server TLS from an existing secretfalse
tls.existingSecretExisting secret with CA, certificate, and key""
tls.requireSecureTransportRequire TLS for TCP client connectionsfalse
tls.volumePermissions.enabledNormalize TLS Secret file ownership and modes before startupfalse
tls.client.enabledUse TLS for chart-managed TCP clientsfalse
tls.client.sslModeMySQL CLI SSL mode for internal chart-managed clientsREQUIRED
serviceAccount.createCreate a ServiceAccountfalse
serviceAccount.automountServiceAccountTokenMount Kubernetes API token into workload podsfalse
externalSecrets.enabledRender ExternalSecret resourcesfalse
externalSecrets.apiVersionExternalSecret API versionexternal-secrets.io/v1
externalSecrets.auth.enabledManage the auth Secret through External Secrets Operatorfalse
externalSecrets.tls.enabledManage the TLS Secret through External Secrets Operatorfalse
externalSecrets.backup.enabledManage the backup Secret through External Secrets Operatorfalse
backup.enabledEnable built-in S3 backup CronJobfalse
backup.scheduleBackup schedule"0 3 * * *"
backup.serviceAccount.createCreate a dedicated ServiceAccount for Pod Identity / IRSA backupstrue
backup.serviceAccount.nameExisting dedicated ServiceAccount for Pod Identity / IRSA backups""
backup.serviceAccount.annotationsAnnotations for the Pod Identity / IRSA ServiceAccount{}
backup.serviceAccount.automountServiceAccountTokenMount the Kubernetes API token into backup podsfalse
backup.s3.endpointS3-compatible endpoint URL""
backup.s3.bucketTarget bucket name""
backup.s3.regionAWS region used by Pod Identity or IRSA backups""
backup.s3.credentialsFromPodIdentityUse the backup pod IAM identity instead of static S3 credentialsfalse
backup.database.mysqldumpArgsExtra mysqldump flags used before --all-databases`"--single-tr

Deploy mysql with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mysql 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 chartmysql is pinned at v2.4.2 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