Kubernetes Operators for MariaDB

Operators basically instruct Kubernetes about how to manage a certain technology. Kubernetes comes with some default operators, but it is possible to create custom operators. Operators created by the community can be found on OperatorHub.io.

Custom Operators

Kubernetes provides a declarative API. To support a specific (i.e. MariaDB) technology or implement a desired behavior (i.e. provisioning a replica), we extend Kubernetes API. This involves creating two main components:

  • A custom resource.
  • A custom controller.

A custom resource adds an API endpoint, so the resource can be managed via the API server. It includes functionality to get information about the resource, like a list of the existing servers.

A custom controller implements the checks that must be performed against the resource to check if its state should be corrected using the API. In the case of MariaDB, some reasonable checks would be verifying that it accepts connections, replication is running, and a server is (or is not) read only.

MariaDB Operator

OperatorHub.io has a MariaDB operator. At the time of this writing it is in alpha stage, so please check its maturity before using it.

MariaDB operator is open source and is released under the terms of the MIT license. The source code is available on GitHub. The README.md file shows usage examples.

It defines the following custom resources:

  • MariaDB server.
  • MariaDB Backup. mariabackup is used.
  • MariaDB Monitor. Prometheus metrics are exposed on port 9090.

There's another alternative that seems to be more actively mantained and provides a more Kubernetes native experience and enhanced security. It's in alpha stage and the code has been open sourced on GitHub (mmontes11/mariadb-operator).

It supports the following features:

  • Provisioning highly configurable MariaDB servers
  • Take and restore backups. Scheduled backups. Backup rotation
  • Bootstrap new instances from a backup
  • Support for managing users, grants and logical databases
  • Prometheus metrics
  • Validation webhooks to provide CRD inmutability
  • Additional printer columns to report the current CRD status
  • CRDs designed according to the Kubernetes API conventions
  • GitOps friendly
  • Multi-arch Docker image
  • Helm chart

It provides README.md as a starting point and also a suite of example CRDs.

Other Operators

If you know about other MariaDB operators, feel free to add them to this page (see Writing and Editing Knowledge Base Articles).

MySQL and Percona Server operators should work as well, though some changes may be necessary to fix incompatibilities or take advantage of certain MariaDB features.

Content initially contributed by Vettabase Ltd.


Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.