Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 10 - Set Up MariaDB Database For Kubernetes

Below are the steps I used to set up a database server for my Kubernetes cluster.

It's not ideal that it is a single databaase server, and not a database cluster for high availability (HA), but it will do for now. When I have a tutorial explaining how to set up a database cluster for HA, I will link to that, but for now, here is an alternative tutorial if you have to have HA.


For my setup, I am using a VPS with 1 GB of RAM and 2 vCPUs.


sudo apt-get install mariadb-server -y

This will install MariaDB 10.3.29 at the time of writing this post.

Log into the database as the root user.

sudo mysql

Create a database for kubernetes to use.


Create a user for Kubernetes to connect to the database with:

CREATE USER 'kubernetes' IDENTIFIED BY 'strongRandomPasswordHere';

Now give the Kubernetes user full access to the Kubernetes database:

GRANT ALL ON kubernetes.* to kubernetes;

Now you are all done, exit the MariaDB CLI interface:


Allow Remote Access

By default, MariaDB only allows local connections, and does not listen to the outside world. We need to change this so that our Kubernetes servers can connect. Copy and paste the following commands which will update the server configuration for you so that the database will listen to the outside world by commenting out the bind address.

SEARCH="bind-address            ="
REPLACE="#bind-address            ="
sudo sed -i "s;$SEARCH;$REPLACE;" $FILEPATH

Now restart the database service for the changes to take effect:

sudo service mysql restart
Last updated: 23rd June 2021
First published: 23rd June 2021