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 https://github.com/kraftcloud/examples
cd examples/mariadb

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

Terminal window
# Set Unikraft Cloud access token
export UKC_TOKEN=token
# Set metro to Frankfurt, DE
export UKC_METRO=fra0

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

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: twilight-sun-82lt4ddk.fra0.kraft.host
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ image: mariadb@sha256:6e31d28b351eb12a070e3074f0a500532d0a494332947e9d8dbfa093d2d551fd
β”œβ”€β”€β”€β”€β”€ boot time: 159.06 ms
β”œβ”€β”€β”€β”€β”€β”€β”€β”€ memory: 1024 MiB
β”œβ”€β”€β”€β”€β”€β”€β”€ service: twilight-sun-82lt4ddk
β”œβ”€β”€ private fqdn: mariadb-w2g2z.internal
β”œβ”€β”€β”€β”€ private ip: 172.16.6.3
└────────── args: /usr/sbin/mariadbd --user=root --log-bin

In this case, the instance name is mariadb-w2g2z; it is different for each run.

To test the deployment, first forward the port with the kraft cloud tunnel command.

Terminal window
kraft cloud tunnel 3306:mariadb-w2g2z: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 127.0.0.1 -u root -punikraft mysql <<< "select count(*) from user"

You should see output such as:

Terminal window
count(*)
6

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
NAME FQDN STATE CREATED AT IMAGE MEMORY ARGS BOOT TIME
mariadb-w2g2z twilight-sun-82lt4ddk.fra0.kra... running 1 minute ago mariadb@s... 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 Unikraft Cloud 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 Unikraft Cloud:

Terminal window
kraft cloud --help

Or visit the CLI Reference.