Deploying MariaDB on Kubernetes
25 Jul 2026, 1:41 pm
MariaDB is a popular open-source relational database. Running it on Kubernetes gets you portability across environments, CI/CD integration, and automated backup/recovery alongside the usual scalability and high-availability benefits. This guide sets up persistent storage, deploys MariaDB as a StatefulSet, exposes it via a Service, and covers scaling. Prerequisites: a Kubernetes cluster with at least 3 nodes and kubectl configured against it.
Create Persistent Volume and Claim Define a PersistentVolume:
Retain keeps the data if the PV is deleted; hostPath backs it with a directory on the node. Define a matching PersistentVolumeClaim:
Confirm status is Bound before continuing.
Deploy the MariaDB StatefulSet Create a ConfigMap for my.cnf:
Create the StatefulSet. Replace strong_password:
Access MariaDB Expose it internally:
Connect with a throwaway client pod:
Scale the Deployment
Scale back down:
Each replica in this setup is an independent MariaDB instance with its own PVC — for real multi-node replication, layer in MariaDB Galera or MaxScale rather than relying on StatefulSet scaling alone.
Next Steps
MariaDB is running on Kubernetes with persistent storage and a scalable StatefulSet. From here: • Swap the hostPath PV for a CSI-backed StorageClass in production so pods can reschedule across nodes • Add readiness/liveness probes on port 3306 for better failure detection • Front the service with an external LoadBalancer or Ingress if clients outside the cluster need access
For the full guide, visit the original article on Vultr Docs.
https://dev.to/vultr/deploying-mariadb-on-kubernetes-408a