kubernetes MySQL InstallationThis week is KubeCon in Detroit, and in preparation for attending I have been polishing up my Kubernetes skills. This big rush to put software in containers and have Kubernetes run everything is getting a lot of push in the industry. Many software applications run perfectly well in ready-made packages from a container made for ephemeral consumption much like a can of Campell’s tomato soup. But generally, relational databases like permanence, stability, and a consistent presence. Databases like to run to stock caches and build statistics, so they are not great at running well after being started. But this article is the first in a series for ‘us’ database folks to learn how to keep our databases happy in a containerized world.

With the trip to the Motor City on my calendar, it was time to answer the question “What is the minimalist Kubernetes installation that I can use to run MySQL?”. I am sharing my steps hoping that others wondering similar questions will find this blog post helpful if not more palatable than a recent can of Campbell’s tomato soup. I pulled out my trusty test mule laptop and installed Ubuntu 22.04.1 LTS with updates. My plan was to run everything needed for a single MySQL instance on the laptop itself.

Googling Kubernetes offerings was exhausting as there are so many different options. Orchestrating Docker containers is what Kubernetes does and there are many choices, most of which are extremely complicated to set up. What was desired was a simple installation with the least number of “moving parts” to get working. I ended up using Minikube as it runs very well running a single-node Kubernetes cluster in a virtual machine on a laptop.

Installing Minikube

Minikube is a “local Kubernetes engine” so we need minimal preparation time and hardware. There are some prerequisite software packages needed when installing Minikube.

We will also need Docker for our container.

Then we can get the latest Minikube and kubectl binaries.

Those binaries need to be given a good home and made executable.

Now that the required software is in place, we start our cluster.

So it looks like all the various components are functional. Now the containerized applications can be deployed.

Okay, now how do we get MySQL to run?

Putting MySQL into a container will seem a bit off for those used to the popular open source database. The first step is to create a file with the MySQL server’s root password. We create a simple password by sending a simple phrase through the base64 program.

And we have to put that password into a file named mysql-secret.yaml

Double-check that the password you received out of base64 is the same as in your file. That yaml file is called a ‘manifest’ and it needs to be applied.

This creates the mysql-pass object. Now we need a manifest for the MySQL object that tells what is needed to run MySQL. Read through it to double-check paths, ports, and mount points.

This manifest also needs to be applied.

At this point in time, we can bash shell to the MySQL container.

We will also need an object to allow other objects to reach MySQL.

Create a mysql-service.yaml with the following contents to make the k8s-mysql pod be reachable:

And activate it too.

At this point, we could add something like a WordPress website and continue (I do hope to build on this at a later date and do just that) to improve our Kubernetes cluster. But for now, we can look back at starting with nothing and building a small cluster using Minikube to support MySQL.

What I hope to do is build on this and discover how the various “tinker toys” communicate as well as how they are controlled. Then we can explore persistent data in a world of short-lived containers and how we can manage them.

For those who want to experiment more with this while I am in Detroit, I refer you to these two articles that I have borrowed liberally from and acknowledge them as great resources:

How to Install Minikube on Ubuntu 22.04 | 20.04

How to Deploy MySQL on Kubernetes

Notify of

Inline Feedbacks
View all comments