This guide shows you how to use Memcached , an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
To run it, 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/memcached/
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 11211:11211/tls -M 256 .
The output shows the instance URL and other details:
[ β ] Deployed successfully!
β ββββββββββ name : memcached-arkv7
β ββββββββββ uuid : da436eca-bc64-46d7-a04c-72832652b10e
β βββββββββ state : running
β ββββββββββ fqdn : weathered-smoke-hehsdinv.fra0.kraft.host
β βββββββββ image : memcached@sha256:f53cdbce4dc185e8acc8ecb93a0ab0ba99085ca0837a0ad2062aae9e31382e58
β βββββ boot time : 19.27 ms
β ββββββββ memory : 256 MiB
β βββββββ service : weathered-smoke-hehsdinv
β ββ private fqdn : memcached-arkv7.internal
β ββββ private ip : 172.16.6.5
β ββββββββββ args : /usr/bin/memcached -u root
In this case, the instance name is memcached-arkv7
; itβs different for each run.
To test the deployment, first forward the port with the kraft cloud tunnel
command:
kraft cloud tunnel 11211:memcached-arkv7:11211
Now, on a separate console, run the following commands to test that it works (you should see output when incrementing):
To exit telnet run:
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 Memcached 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
memcached-arkv7 weathered-smoke-hehsdinv.fra0.... running 11 minutes ago memcached@sha256:f53cdbce4... 256 MiB /usr/bin/memcached -u root 19266us
When done, you can remove the instance:
kraft cloud instance remove memcached-arkv7
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
runtime : memcached:latest
cmd : [ " /usr/bin/memcached " , " -u " , " root " ]
FROM debian:bookworm AS build
Learn More
Use the --help
option for detailed information on using Unikraft Cloud:
Or visit the CLI Reference .