MySQL Operator for Kubernetes

A technology that allows making MySQL databases stateful within a Kubernetes cluster

Scenario

When it comes to innovation in terms of application development and deployment methods, the microservices approach has gained significant popularity in recent years. This approach differs from the traditional monolithic one. The monolithic approach involves compiling all the libraries and various components of an application into a single executable, which is then distributed on usually physical machines.

The microservices approach, on the other hand, requires that the various parts that make up an application are separated and then interconnected to ensure flexibility, lightweight executables, and resilience. In this case, the various microservices are distributed on virtual machines or Docker containers.

Each microservice has its own life and is developed to interact with others to enable the overall functioning of the application. In the event that a microservice running on virtual machines or Containers encounters errors or interrupts its execution, manual intervention is required. Kubernetes is a service that automates and simplifies the lifecycle management of microservices.

In Kubernetes, each microservice is typically represented by a Pod that runs one or more Docker Containers. Kubernetes' strategy is to restart Pods if their execution is interrupted, so these should be thought of as stateless services. Even the database component (whether MySQL, Postgres, etc.) is governed through a microservice and therefore a Pod, but a database is by definition a stateful process. Therefore, in the event of a Pod restart, all the data it possessed would be lost, unless backup and restore policies that may not meet the application's requirements are in place.

In the case of a MySQL InnoDB architecture, there would be various complexities introduced by maintenance, updates, and application administration. One example is the need to control the activation and shutdown sequence of nodes. It can be concluded that managing such activities through the Kubernetes paradigm alone becomes too complex to sustain.

Solution

To address this issue that severely limits the use of databases through Kubernetes, Technology Reply proposes the solution announced by Oracle: the MySQL Operator for Kubernetes. Through Kubernetes Operators, it is possible to define custom Kubernetes resources that extend Kubernetes' own functionality.

Kubernetes Operators allow integrating new functionalities into the existing mechanisms and logic of Kubernetes. They are software extensions that, through the use of custom resources, enable the management of applications and their components.

The introduction of the MySQL Operator for Kubernetes aims to easily and effectively install and manage a MySQL InnoDB Cluster within Kubernetes. This operator allows, for example, the control of MySQL database Pod behavior in the event of software or hardware failures.

As mentioned earlier, by default, Pods that encounter errors are restarted by Kubernetes, and therefore, all data that these Pods were using is not preserved. Consequently, Pods must be developed with a stateless approach.

With the MySQL Operator, Oracle offers a solution that allows managing a stateful MySQL database hosted in a Pod by controlling its lifecycle and other aspects such as software component releases and updates, TLS certificate management, and the configuration of the number of Pod replicas hosting the database.

Advantages

The MySQL Operator for Kubernetes aims to simplify the deployment of MySQL databases in Kubernetes clusters. Some of the advantages offered by this operator are:

  • Automated Deployment: Thanks to Kubernetes primitives, deployment procedures are automated and simplified for easy integration into DevOps workflows.
  • High Availability: Through the replication of Pods hosting the MySQL database, it ensures that there is always at least one process ready to respond to incoming requests.
  • Self-Healing: MySQL processes can restart, thanks to Kubernetes primitives, in case of failure, ensuring that data and transactions managed by the MySQL database are not lost.
  • Scaling: It is possible to increase or decrease the number of Pod replicas hosting the MySQL database based on the instantaneous load conditions on the running Pods.
  • Backup: The operator offers an automatic mechanism for creating and managing backups of the database content.


Our Team

Technology Reply offers its expertise and skills to clients for implementing and monitoring Cloud solutions for their processes, with a particular focus on on-cloud MySQL database implementation. This knowledge and capability were showcased at the latest Oracle MySQL Day in Rome, where the Technology Reply team presented the innovations and advantages introduced by the MySQL Operator for Kubernetes to enthusiasts and MySQL users.