Debian 10 - Set Up MariaDB Database For Kubernetes
Below are the steps I used to set up a database server for my Kubernetes cluster.
For my setup, I am using a VPS with 1 GB of RAM and 2 vCPUs.
sudo apt-get install mariadb-server -y
Log into the database as the root user.
Create a database for kubernetes to use.
CREATE DATABASE kubernetes;
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 = 127.0.0.1"
REPLACE="#bind-address = 127.0.0.1"
sudo sed -i "s;$SEARCH;$REPLACE;" $FILEPATH
Now restart the database service for the changes to take effect:
sudo service mysql restart
First published: 23rd June 2021