This guides shows you how to use Redis , an open-source in-memory storage, used as a distributed, in-memory keyβvalue database, cache and message broker, with optional durability.
To run it example, follow these steps:
Install the kraft
CLI tool and a container runtime engine, e.g. Docker.
Clone the examples
repository and cd
into the examples/redis/
directory:
git clone https://github.com/kraftcloud/examples
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 token
# Set metro to Frankfurt, DE
When done, invoke the following command to deploy this application on Unikraft Cloud:
kraft cloud deploy -p 6379:6379/tls -M 512 .
The output shows the instance URL and other details:
[ β ] Deployed successfully!
β ββββββββββ name : redis-alb4r
β ββββββββββ uuid : d3c3141b-97b2-4e1d-87ae-39e4f14ab49e
β βββββββββ state : running
β ββββββββββ fqdn : rough-wind-8vxrd1ms.fra0.kraft.host
β βββββββββ image : redis@sha256:9665c51faf7deb538cf7907b012b55700cad08cd391f5ba099d95d018c8da7d
β βββββ boot time : 26.13 ms
β ββββββββ memory : 512 MiB
β βββββββ service : rough-wind-8vxrd1ms
β ββ private fqdn : redis-alb4r.internal
β ββββ private ip : 172.16.6.2
β ββββββββββ args : /usr/bin/redis-server /etc/redis/redis.conf
In this case, the instance name is redis-alb4r
; itβs different for every run.
To test the deployment, first forward the port with the kraft cloud tunnel
command:
kraft cloud tunnel 6379:memcached-arkv7:6379
Then, from another console, you can now use the redis-benchmark
client to connect to Redis, for example:
redis-benchmark -t ping,set,get -n 10000
You should see output similar to:
====== PING_INLINE ======
10000 requests completed in 32.03 seconds
host configuration "save":
host configuration "appendonly": no
0.01% <= 138 milliseconds
0.05% <= 139 milliseconds
2.34% <= 140 milliseconds
4.49% <= 141 milliseconds
8.57% <= 142 milliseconds
16.06% <= 143 milliseconds
21.83% <= 144 milliseconds
26.25% <= 145 milliseconds
34.54% <= 146 milliseconds
To disconnect, simply kill the tunnel
command with ctrl-C
Note
We use kraft cloud tunnel
only when a service doesnβt support TLS and is not HTTP-based (we use TLS/SNI to determine the correct instance to send traffic to).
Also note that tunnel
command is not needed when connecting via an instanceβs private IP/FQDN, ie, when a Redis instance is used as a backend to
another instance that acts as a frontend and which does support TLS.
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 TIME
redis-alb4r rough-wind-8vxrd1ms.fra0.kraft... running 1 minute ago redis@sha256:9665c51faf7deb5... 512 MiB /usr/bin/redis-server /etc/red... 26131us
When done, you can remove the instance:
kraft cloud instance remove redis-alb4r
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
cmd : [ " /usr/bin/redis-server " , " /etc/redis/redis.conf " ]
FROM debian:bookworm AS build
Learn More
Use the --help
option for detailed information on using Unikraft Cloud:
Or visit the CLI Reference .