Zudoku
Tutorials

KraftKit To Unikraft

This tutorial shows how to migrate from the legacy kraft cloud CLI to the new unikraft CLI for Unikraft Cloud. It focuses on the differences that matter during day-to-day work: authentication, profiles, deployment flow, common commands, and flag behaviour.

Prerequisites

Make sure you have the new CLI installed. See the unikraft CLI overview for installation instructions. If you still need the legacy syntax during the migration, keep the kraft cloud reference nearby.

Main mental shift

The biggest change is that the legacy CLI combines packaging and deployment into a single command, while the new CLI treats them as separate operations.

In the legacy flow:

TerminalCode
kraft cloud deploy \ -p 443:8080/http+tls \ -M 512Mi \ --rootfs-type erofs \ .

the CLI reads the local project, builds the root filesystem and image if needed, pushes it, and starts an instance.

In the new flow, the CLI splits the same work into two clearer stages:

TerminalCode
unikraft build . --output <my-org>/my-app:latest unikraft run --metro fra \ -p 443:8080/http+tls \ -m 512M \ --image <my-org>/my-app:latest

This split has two practical consequences:

  • unikraft build is where you package the image and store it in a registry.
  • unikraft run is where you create an instance from an existing image and set runtime options such as ports, memory, scale-to-zero, volumes, and environment variables.

That separation makes the deployment flow more explicit. It also means you need to think about whether a flag belongs to image creation time or instance runtime.

Login and authentication

Public Unikraft Cloud

For the public service, the new CLI uses an interactive login flow that opens a browser window to authenticate with the Unikraft Cloud dashboard. The legacy CLI relies on environment variables to store the access token and metro selection.

unikraft login

The environment variables UKC_TOKEN and UKC_METRO are only supported by the legacy CLI. They aren't the normal way to authenticate with the new CLI.

Profile management

The new CLI uses profiles to manage authentication and configuration for different environments. The default profile contains all the publicly available metros:

TerminalCode
unikraft profile list
TerminalCode
NAME ACTIVE METROS default true ["fra0", "dal0", "sin0", "was1", "fra", "dal", "sin", "was", "sfo"]

Thus, listing instances with unikraft is more convenient than with kraft cloud:

unikraft instances list
METRO NAME STATE IMAGE ARGS MEMORY VCPUS FQDN CREATED fra httpserver-go121-qdrlz stopped <my-org>/httpserver-go121 256MiB 1 summer-star-huyfslqm.fra.unikraft.app 20 hours ago fra httpserver-go121-bhjvm stopped <my-org>/httpserver-go121 256MiB 1 restless-gorilla-dalzi9bs.fra.unikraft.app 20 hours ago was httpserver-go121-xjsli standby <my-org>/httpserver-go121 256MiB 1 bitter-bonobo-20plsjfu.was.unikraft.app 2 minutes ago

Write operations require an explicit metro selection with --metro:

TerminalCode
unikraft run --metro fra \ -p 443:8080/http+tls \ -m 512Mi \ --image <my-org>/my-app:latest

For custom or private metros, define a profile in ~/.config/unikraft/config.yaml:

YAMLCode
profiles: <metro_subdomain>: type: cloud token: <ukc_token> organization: <ukc_user> metros: - name: <metro_subdomain> endpoint: https://api.<metro_subdomain>.unikraft.cloud country: <country_code>

Then select it explicitly:

TerminalCode
unikraft profile use <metro_subdomain> unikraft profile list

If you work against more than one metro or installation, create one profile per environment and switch with unikraft profile use instead of rewriting shell variables. This has the advantage of persistence through configuration files.

Translate the most common commands

Use the following mappings as a quick migration reference.

Log in

unikraft login

Select a configured environment

unikraft profile use <profile>

Build and push an image

unikraft build . --output <my-org>/my-app:latest

Run an instance from an image

unikraft run --metro fra \ -p 443:8080/http+tls \ -m 512M \ --image <my-org>/my-app:latest

List instances

unikraft instances list

Remove an instance

unikraft instances delete <name>

Create a volume

unikraft volume create \ --metro fra \ --name data \ --size 200M

Flags differences

Memory units

Memory units behave differently in the new CLI.

unikraft run --metro fra \ -m 512M \ --image <my-org>/my-app:latest

unikraft only accepts units in the binary system, for example, 512M or 512MiB for Mebibytes. The legacy kraft cloud works with the decimal system as well—so 512M would mean 512 Megabytes, which is about 488 Mebibytes, while 512Mi would mean 512 Mebibytes, which is about 536 Megabytes.

Scale-to-zero

The new CLI folds three legacy switches into one structured flag:

unikraft run --metro fra \ --scale-to-zero policy=idle,cooldown-time=5000,stateful=true \ --image <my-org>/my-app:latest

Not specifying any scale-to-zero configuration means don't scale-to-zero. Note that, besides policy, each of the options for scale-to-zero are optional.

Filtering and waiting

The new CLI adds a rich filter language for many commands. For example:

TerminalCode
unikraft instances list --filter 'state==running,metro==fra'

and:

TerminalCode
unikraft instance wait my-instance --until state==running

These --filter and --until expressions are features of the new CLI. They aren't available in the legacy kraft cloud CLI. See Fields for the full syntax.

A side-by-side migration example

Suppose your old workflow looked like this:

TerminalCode
# do this once in every terminal session export UKC_TOKEN=token export UKC_METRO=fra kraft cloud deploy -n my-app -p 443:8080/http+tls -M 512Mi -e APP_ENV=production . kraft cloud instance get my-app kraft cloud instance logs my-app -f kraft cloud instance remove my-app

The migrated workflow is:

TerminalCode
unikraft build . --output <my-org>/my-app:latest unikraft run --metro fra -n my-app -p 443:8080/http+tls -m 512M -e APP_ENV=production --image <my-org>/my-app:latest unikraft instances get my-app unikraft instance logs my-app -f unikraft instances delete my-app

Note the absence of environment variable exports in the new CLI, which uses persistent profiles instead.

Migration checklist

When moving an existing guide, script, or workshop from kraft cloud to unikraft, check the following:

  • Replace kraft cloud deploy with unikraft build plus unikraft run;
  • Move the local path such as . to unikraft build;
  • Add an explicit image reference with --output on build and --image on run;
  • Replace legacy authentication environment variables with unikraft login or a configured profile;
  • Move run-time flags such as memory, ports, env vars, volumes, and scale-to-zero settings to unikraft run;
  • Translate legacy scale-to-zero flags into the structured --scale-to-zero syntax;
  • Update instance management commands such as list and delete to the new command names;
  • Take advantage of new --filter and --until flags where they simplify scripts.

The legacy kraft cloud CLI

The unikraft CLI replaces the deprecated kraft cloud CLI. Use it for all work on Unikraft Cloud.

Unikraft no longer recommends the kraft cloud CLI.

Learn more

Use the --help option for detailed information on using Unikraft Cloud:

unikraft --help

For more details, check the following references:

Last modified on