Skip to content

Deploy Redis

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:

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

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

Terminal window
git clone https://github.com/kraftcloud/examples
cd examples/redis/

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
export KRAFTCLOUD_TOKEN=token
# Set metro to Frankfurt, DE
export KRAFTCLOUD_METRO=fra0

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

Terminal window
kraft cloud deploy -p 6379:6379/tls -M 512 .

The output shows the instance URL and other details:

Terminal window
[●] 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 group: 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 and the service group rough-wind-8vxrd1ms. 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 rough-wind-8vxrd1ms 6379:6379

Then, from another console, you can now use the redis-benchmark client to connect to Redis, for example:

Terminal window
redis-benchmark -t ping,set,get -n 10000

You should see output similar to:

Terminal window
====== PING_INLINE ======
10000 requests completed in 32.03 seconds
50 parallel clients
3 bytes payload
keep alive: 1
host configuration "save":
host configuration "appendonly": no
multi-thread: 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

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
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:

Terminal window
kraft cloud instance remove redis-alb4r

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: redis:latest
rootfs: ./Dockerfile
cmd: ["/usr/bin/redis-server", "/etc/redis/redis.conf"]

Learn More

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

Terminal window
kraft cloud --help

Or visit the CLI Reference.