Chapter 32

MySQL on Kubernetes

MySQL on Kubernetes

Running MySQL on Kubernetes brings cloud-native benefits (elasticity, standardization) but requires careful handling of stateful workloads.

Operator Pattern

Use an Operator rather than raw StatefulSets. Operators encode operational knowledge — handling failover, backups, and scaling automatically. Percona Operator for MySQL is the most production-ready open-source option, supporting both Group Replication and classic primary/replica topologies.

StatefulSet Essentials

Storage

Use reclaimPolicy: Retain — the default Delete will destroy EBS volumes on PVC deletion. Use Local PV for maximum I/O or EBS gp3/io2 on AWS with WaitForFirstConsumer binding to ensure same-AZ placement.

Backups

CronJob running percona/percona-xtrabackup nightly, syncing to S3. Combine with binlog shipping for point-in-time recovery.

Observability

Deploy prom/mysqld-exporter as a sidecar or separate Deployment. Key alerts: connection pool utilization >80%, replica lag >30s, slow query rate spike.

Rate this chapter
4.8  / 5  (3 ratings)

💬 Comments