v0.1.2 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2018 License: Apache-2.0


MySQL Operator

MySQL Operator is a bulletproof MySQL on Kubernetes. It manages all the necessary resources for a MySQL CLuster deployment.

The MySQL Operator provides efortless backups, while the cluster being highly-available.

MySQL Operator was developed by the awesome engineering team at Presslabs, a Managed WordPress Hosting provider.

For more open-source projects, check Presslabs Code.


The main goals of this operator are:

  1. Easily deploy mysql clusters in kubernetes (cluster-per-service model)
  2. Friendly devops (monitoring story solved)
  3. Out-of-the-box backups (automated and on demand) and point-in-time recovery
  4. Support for cloning in cluster and across clusters

Controller deploy

To deploy this controller, use the provided helm chart, by running:

helm repo add presslabs
helm install presslabs/mysql-operator

This chart will deploy the controller and an orchestrator cluster.

Example of a cluster

Before creating a cluster, we need a secret that contains the ROOT_PASSWORD to init mysql with (an example for this secret can be found here). Now, to create a cluster we need just a simple yaml file that defines it — let's call it cluster.yaml and can be as follows:

kind: MysqlCluster
  name: foo
  replicas: 2
  secretName: the-secret

For a more in depth configuration, check examples. To deploy this cluster, run:

kubectl apply -f cluster.yaml

To list the deployed clusters use:

$ kubectl get mysql
foo       1m

To check cluster state use:

$ kubectl describe mysql foo
  Ready Nodes:  2
    Last Transition Time:  2018-03-28T10:20:23Z
    Message:               Cluster is ready.
    Reason:                statefulset ready
    Status:                True
    Type:                  Ready

Example of a backup

Making a backup is easy — defining a cluster, you should define a backup; for a detailed example, check this example. Let's define a new one on:

kind: MysqlBackup
  name: foo-backup
  clusterName: foo

To deploy the backup, run:

kubeclt apply -f backup.yaml

To lists all backups, run:

$ kubectl get backup
NAME                             AGE
foo-backup                       1m

To check backup state and details, use:

$ kubectl describe backup foo-backup
  Completed:  true
    Last Transition Time:  2018-03-21T16:02:56Z
    Status:                True
    Type:                  Complete
    Last Transition Time:  2018-03-21T16:02:48Z
    Message:               First initialization of backup
    Reason:                set defaults
    Status:                Unknown
    Type:                  Failed

Tech considerations

This project uses Percona Server for MySQL 5.7 because of backup improvements (eg. backup locks), monitoring improvements and some serviceability improvements (eg. utility user). The case against MariaDB is that WordPress requires MySQL, but MariaDB is not a drop-in replacement for it, since MariaDB 10 is a fork, rather than following MySQL.


This project is licensed under Apache 2.0 license. Read the LICENSE file in the top distribution directory, for the full license text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL