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:
-
Install the
kraft
CLI tool and a container runtime engine, e.g. Docker. -
Clone the
examples
repository andcd
into theexamples/mariadb/
directory:
git clone https://github.com/kraftcloud/examplescd 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:
# Set Unikraft Cloud access tokenexport UKC_TOKEN=token# Set metro to Frankfurt, DEexport UKC_METRO=fra0
When done, invoke the following command to deploy this application on Unikraft Cloud:
kraft cloud deploy -p 3306:3306/tls -M 1024 .
The output shows the instance URL and other details:
[β] 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.
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:
mysql -h 127.0.0.1 --ssl-mode=DISABLED -u root -punikraft mysql <<< "select count(*) from user"
Alternatively, use the mariadb
client command line tool:
mariadb -h 127.0.0.1 --ssl=OFF -u root -punikraft mysql <<< "select count(*) from user"
You should see output such as:
count(*)6
To disconnect, kill the tunnel
command using Ctrl+c
.
At any point in time, you can list information about the instance:
kraft cloud instance list
NAME FQDN STATE CREATED AT IMAGE MEMORY ARGS BOOT TIMEmariadb-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:
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 argumentsDockerfile
: 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"]
FROM debian:bookworm AS build
RUN set -xe \ echo "Your code here"
FROM scratch
# Your files here# COPY --from=build / /
Learn More
Use the --help
option for detailed information on using Unikraft Cloud:
kraft cloud --help
Or visit the CLI Reference.