Introducing NDB Operator : The Kubernetes Operator for MySQL NDB Cluster

Lakshmi Narayanan Sreethar
3 min readSep 9, 2021

The Kubernetes Operator for MySQL NDB Cluster, a.k.a. the NDB Operator, is being developed by the MySQL NDB Cluster team at Oracle, to simplify the effort required to start and manage a MySQL NDB Cluster inside Kubernetes Cluster. An early preview release of the same is now available at — https://github.com/mysql/mysql-ndb-operator.

This version of the NDB operator has a partial Level 1 Capability. Key features of this release include :

  • Provision and run a MySQL Cluster based on the given configuration
  • Elastically scale up and down the number of MySQL Servers connected to the MySQL Cluster
  • Apply a limited set of configuration changes to the MySQL Cluster with no down time
  • Automatic recovery from hardware failure by migrating affected MySQL Cluster nodes to healthy hardware

The simplest way to install the NDB Operator in an existing Kubernetes Cluster is to directly use the deploy manifest provided in the repository :

kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-ndb-operator/main/deploy/manifests/ndb-operator.yaml

Another way to install the NDB Operator is to use the helm chart provided in the repository. Either way, the following resources will be installed in the Kubernetes Cluster :

The operator will be ready to manage MySQL Clusters once the pods running the web server and the operator are ready. To list and verify the readiness of those pods, run :

kubectl get pods \
--namespace=ndb-operator \
--selector='app in (ndb-operator,ndb-operator-webhook-server)'

Once the operator is ready, a MySQL NDB Cluster can be started inside the Kubernetes Cluster, by creating an object of kind NdbCluster, that has the desired configuration of that MySQL Cluster. The source code at Github includes a few sample NdbCluster objects using which one can deploy a MySQL Cluster with a basic configuration.

For example, the example-ndb.yaml file defines a MySQL Cluster with two Replicas, two Data Nodes and two MySQL Servers :

apiVersion: mysql.oracle.com/v1alpha1
kind: NdbCluster
metadata:
name: example-ndb
spec:
nodeCount: 2
redundancyLevel: 2
mysqld:
nodeCount: 2

To start a MySQL Cluster with this configuration, run :

kubectl apply -f docs/examples/example-ndb.yaml

NDB Operator will then deploy the required MySQL Cluster nodes, using the mysql/mysql-cluster:latest container image. The pods created by the operator can be viewed using :

kubectl get pods -l mysql.oracle.com/v1alpha1=example-ndb

The README.md file further explains how to connect to the MySQL Cluster once all the pods are ready.

NDB Operator thus provides an abstraction over the complexity and simplifies the effort required to start and manage a MySQL NDB Cluster inside the Kubernetes Cluster. Future releases will improve the NDB Operator further and make it even easier to run and manage a MySQL NDB Cluster in the Kubernetes Cluster.

Please visit the repository at https://github.com/mysql/mysql-ndb-operator for more information. We also welcome ideas, contribution and feedback from the community. The MySQL NDB Cluster team is available at the MySQL community workspace on Slack (Request an invite here).

--

--

Lakshmi Narayanan Sreethar

Principal Member Technical Staff at Oracle, working in the MySQL NDB Cluster team.