Redis
This guide 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, follow these steps:
-
Install the CLI. Use the unikraft CLI or the legacy kraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.
-
Clone the
examplesrepository andcdinto theexamples/redis7.2/directory:
Code
Make sure to log into Unikraft Cloud and pick a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
When done, invoke the following command to deploy this app on Unikraft Cloud:
The output shows the instance address and other details:
In this case, the instance name is redis72-alb4r which is different for every run.
To test the deployment, first forward the port using socat:
Code
Then, from another console, you can now use the redis-benchmark client to connect to Redis, for example:
Code
You should see output like:
Code
To disconnect, kill the socat command with ctrl-C.
Note: This guide uses
socatfor port forwarding only when a service doesn't support TLS and isn't HTTP-based (TLS/SNI determines the correct instance to send traffic to). Also note that port forwarding isn't needed when connecting via an instance's private IP/FQDN. For example, when a Redis instance serves as a cache server to another instance that acts as a frontend and which does support TLS.
You can list information about the instance by running:
When done, you can remove the instance:
Customize your app
To customize the app, 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
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Or visit the CLI Reference or the legacy CLI Reference.