Skip to content

Deploy MariaDB

This guide shows you how to use MariaDB, one of the most popular open source relational databases. To run it, follow these steps:

  1. Install the kraft CLI tool and a container runtime engine, e.g. Docker.

  2. Clone the examples repository and cd into the examples/mariadb/ directory:

Terminal window
git clone
cd examples/mariadb

Make sure to log into KraftCloud by setting your token and a metro close to you. We use fra0 (Frankfurt, πŸ‡©πŸ‡ͺ) in this guide:

Terminal window
# Set KraftCloud access token
# Set metro to Frankfurt, DE

When done, invoke the following command to deploy this application on KraftCloud:

Terminal window
kraft cloud deploy -p 3306:3306/tls -M 1024 .

The output shows the instance URL and other details:

Terminal window
[●] Deployed successfully!
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ name: mariadb-w2g2z
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ uuid: ba696c22-adff-4fba-88b9-d1b790ca2357
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ state: running
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ fqdn:
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ image: mariadb@sha256:6e31d28b351eb12a070e3074f0a500532d0a494332947e9d8dbfa093d2d551fd
β”œβ”€β”€β”€β”€β”€ boot time: 159.06 ms
β”œβ”€β”€β”€β”€β”€β”€β”€β”€ memory: 1024 MiB
β”œβ”€ service group: twilight-sun-82lt4ddk
β”œβ”€β”€ private fqdn: mariadb-w2g2z.internal
β”œβ”€β”€β”€β”€ private ip:
└────────── args: /usr/sbin/mariadbd --user=root --log-bin

In this case, the instance name is mariadb-w2g2z and the service group twilight-sun-82lt4ddk. They are different for each run.

To test the deployment, first forward the port with the kraft cloud tunnel command. Be sure to use the service group returned by the kraft cloud deploy command:

Terminal window
kraft cloud tunnel twilight-sun-82lt4ddk 3306:3306

You can now, on a separate console, use the mysql command line tool to test that the set up works:

Terminal window
mysql -h -u root -punikraft mysql <<< "select count(*) from user"

You should see output such as:

Terminal window

To disconnect, simply kill the tunnel command with ctrl-C

At any point in time, you can list information about the instance:

Terminal window
kraft cloud instance list
mariadb-w2g2z twilight-sun-82lt4ddk.fra0.kra... running 1 minute ago 1.0 GiB /usr/sbin/mariadbd --user=ro... 159065us

When done, you can remove the instance:

Terminal window
kraft cloud instance remove mariadb-w2g2z

Customize your Application

To customize the application, update the files in the repository, listed below:

  • Kraftfile: the KraftCloud specification, including command-line arguments
  • Dockerfile: In case you need to add files to your instance’s rootfs
spec: v0.6
runtime: mariadb:latest
rootfs: ./Dockerfile
cmd: ["/usr/sbin/mariadbd", "--user=root", "--log-bin"]

Learn More

Use the --help option for detailed information on using KraftCloud:

Terminal window
kraft cloud --help

Or visit the CLI Reference.