Does MySQL Work With Kubernetes?

Fully CompatibleLast verified: 2026-02-26

MySQL works excellently with Kubernetes through containerization and StatefulSets, enabling production-grade database deployments on K8s clusters.

Quick Facts

Compatibility
full
Setup Difficulty
Moderate
Official Integration
No — community maintained
Confidence
high
Minimum Versions
MySQL: 5.7
Kubernetes: 1.14

How MySQL Works With Kubernetes

MySQL runs seamlessly on Kubernetes by containerizing the database in Docker and managing it through StatefulSets, which provide stable network identities and persistent storage—critical for databases. Kubernetes handles orchestration, scaling, and self-healing, while PersistentVolumes ensure data survives pod restarts. The typical developer experience involves deploying MySQL via Helm charts (like Bitnami's official chart) or writing custom StatefulSet manifests, configuring PersistentVolumeClaims for storage, and exposing the database via Services. The main architectural consideration is choosing between single-instance setups for development and multi-replica configurations with replication for production high-availability. Kubernetes's init containers can handle schema initialization, and Jobs can manage backups. Most teams use managed options like Google Cloud SQL or AWS RDS for production rather than self-hosted K8s MySQL due to operational overhead, but on-cluster deployment works well for dev/test environments and specific workloads.

Best Use Cases

Development and testing environments where MySQL needs to scale alongside application deployments
Microservices architectures where multiple services need dedicated MySQL instances with isolated storage
Multi-tenant SaaS platforms using separate MySQL databases per tenant with dynamic provisioning
CI/CD pipelines requiring ephemeral database instances that spin up and tear down with test suites

Deploy MySQL on Kubernetes with StatefulSet

bash
helm repo add bitnami https://charts.bitnami.com/bitnami && helm repo update
bash
# Install MySQL via Helm (recommended)
helm install mysql bitnami/mysql \
  --set auth.rootPassword=secretpassword \
  --set primary.persistence.size=10Gi

# Or deploy custom StatefulSet
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql
spec:
  serviceName: mysql
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:8.0
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "rootpass"
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  clusterIP: None
  selector:
    app: mysql
  ports:
  - port: 3306
    targetPort: 3306
EOF

# Connect from pod
kubectl run -it --rm mysql-client --image=mysql:8.0 -- \
  mysql -h mysql -u root -prootpass

Known Issues & Gotchas

critical

Data loss if PersistentVolume backend fails without replication configured

Fix: Always use PersistentVolumes backed by redundant storage (cloud provider managed storage), implement MySQL replication, or use managed database services

warning

StatefulSet scaling is not automatic; manual replica configuration required for HA

Fix: Use Helm charts with built-in replication templates, or implement MySQL Operator for automated failover and scaling

warning

Network policies and Service DNS can cause connection timeouts if not properly configured

Fix: Verify Service DNS names, check NetworkPolicies allow traffic, use headless Services for StatefulSets

info

Performance degradation from container resource limits if not sized appropriately

Fix: Set appropriate CPU/memory requests and limits based on workload, monitor with Prometheus/Grafana

Alternatives

  • PostgreSQL with Kubernetes + Helm/CloudNativePG operator (better ACID compliance, superior K8s integration)
  • AWS RDS + EKS (fully managed database removes operational burden)
  • MongoDB with Kubernetes (document-oriented, better horizontal scaling patterns)

Resources

Related Compatibility Guides

Explore more compatibility guides