Installing MariaDB Kubernetes with the Operator

MariaDB Kubernetes Operator assists in deploying and managing various database cluster topologies. With a Custom Resource Definition (CRD), MariaDB Kubernetes Operator extends the Kubernetes API, enabling additional functionality such as scaling a deployment up or down without restarting the cluster. The Operator includes a controller that utilizes the CRD to administer and scale MariaDB resources on Kubernetes.

It requires:

  • Docker version 17+
  • Kubernetes version 1.10+
  • Docker Registry
  • kubectl

Downloading the Operator

MariaDB Kubernetes Operator is available as a .tar.gz from MariaDB Corporation. Untar it into a directory convenient to your use-case or system.

$ mkdir /opt/mariadb-operator
$ tar xvzf mariadb-operator-0.1.3.tar.gz -C /opt/mariadb-operator
$ cd /opt/mariadb-operator

The download includes a Docker image for MariaDB Kubernetes Operator, mariadb-operator-image-0.1.3.tar, which you can import into your Kubernetes cluster. Set the image name and tag to a local value convenient for your uses. For instance, the following command both imports the tar file and tags the result as local/mariadb/operator:0.1.3.

$ docker tag `docker load mariadb-operator-image-0.1.3.tar` local/mariadb/operator:0.1.3

You may need to further specify the image when using a personal Docker Hub (such as johnsmith/mariadb/operator:0.1.3) or when using a Google Cloud repository (such as gcr.io/johnsmith/mariadb/operator:0.1.3). Ensure that your local Docker command-line utility is authorized to push to the remote repository, then use the push command to make the image available in your cluster.

$ docker push local/mariadb/operator:0.1.3

Post-installation Configuration

In the resources/ directory of the MariaDB Kubernetes Operator download, there are YaML files to perform installation configuration tasks. First, use kubectl to install the Custom Resource Definition for MariaDB:

$ kubectl create -f resources/mariadb-crd.yaml

Then, create a service account and set up security (which requires the cluster-admin role):

$ kubectl create -f resources/mariadb-rbac.yaml

Last, deploy the controller. Running the controller requires that the kube-system namespace have the admin namespace. Edit the resources/mariadb-operator.yaml file and update the image attribute to use your custom image.

...
spec:
  serviceAccountName: mariadb-operator
  containers:
  - image: local/mariadb/operator:0.1.3
...

Once done, use the updated mariadb-operator.yaml file with kubectl to create the resource:

$ kubectl create -f resources/mariadb-operator.yaml

Starting the Cluster

When using MariaDB Kubernetes Operator, clusters are defined with the application's YaML script. For instance,

$ cat masterslave-example.yaml

apiVersion: "mariadb.com/v1alpha1"
kind: MariaDB
metadata:
 name: masterslave-example
spec:
 cluster:
   topology: masterslave

Then use kubectl to create the cluster:

$ kubectl create -f masterslave-example.yaml --namespace=mariadb-dev

Example Code

MariaDB Kubernetes Operator ships with a number of YaML files in the examples/ directory for starting various database topologies and for reference in developing your own custom resources. These include the sizes-SML.yaml file, which provides a catalog of predefined MariaDB sizes (small, medium, large).

In order to use the catalog, you first need to create the resource:

$ kubectl create -f examples/sizes-SML.yaml \
  --namespace=<your-namespaace>

MariaDB Server

In cases where you want to support transactional workloads, MariaDB Kubernetes Operator provides four YaML files for initializing different topologies of the MariaDB Server.

  • standalone.yaml: Deploys a single MariaDB Server. This is useful for development use-cases and small transactional workloads.
  • masterslave.yaml: Deploys three MariaDB Servers, one configured as a replication master and two as replication slaves, as well as two MariaDB MaxScale instances for load balancing. This is useful for transactional workloads that require high availability for reads.
  • masterslave-small.yaml: Deploys three MariaDB Servers, one configured as a replication master and two as replication slaves, all of the small size, as well as two MariaDB MaxScale instances for load balancing. This is useful for small transactional workloads that require high availability for reads.
  • galera.yaml: Deploys three MariaDB Servers configured to operate as nodes in Galera Cluster, with two MaxScale instances for load balancing. This is useful for large transactional workloads that require high availability for reads.

MariaDB ColumnStore

In cases where you want to support analytical workloads, MariaDB Kubernetes Operator provides two YaML files for initializing different topologies of MariaDB ColumnStore.

  • columnstore-standalone.yaml: Deploys a MariaDB ColumnStore User Module and two Performance Modules on a single Kubernetes Pod. This is useful if you want to experiment with small analytical workloads on data-sets less than 1 TB.
  • columnstore.yaml: Deploys a MariaDB ColumnStore User Module and a default of three Performance Modules. This is useful if you want to experiment with large analytical workloads.

Comments

Comments loading...