kraft. In this document we outline general practices and different methods for building new applications from scratch or converting existing applications to a unikernel.
Before beginning, it's important to famliarize yourself with the general understanding of what a unikernel is and Unikraft's underlying build process. This can help you better troubleshoot issues may run into when building your application as a unikernel.
There are several different ways you can build a unikernel using Unikraft and
kraft. Fundementally, there are two ways in which a unikernel can be
To compile code natively against the Unikraft library Operating System (which generally has better performance). In this first scenario, the user-level application code is written in a compile-time language, like C, Go or Rust.
The first step in preparing your application to be built or run with Unikraft is
to create a top-level
Kraftfile in your source repository.
Kraftfile is the static configuration
file used to programmatically build and package
a unikernel using
kraft. This file contains information about the Unikraft
core build system, third-party libraries, all configuration options which are
used for the build and a list of possible targets for the application. For all
components, you can define KConfig options
which set options and their respective values.
To discover more options or to set things graphically, you can invoke:
In the above example, the "Hello, world!" example
application was configured by hand
using Unikraft's built-in menuconfig
qemu/x86_64. Colored ANSI output and the internal test suite,
uktest, were selected and enabled for the build.
The configuration for the application is written to a new file and not the original
Kraftfile. Instead, for
qemu/x86_64, it is written to
.config.helloworld_qemu-x86_64in the project directory. This
.config.*file is an intermediate file that is generated from either a
Kraftfileor from running
kraft menu. This
.config*file is the source-of-truth for
kraftin terms of build-time configuration.
Projects that are compiled against Unikraft, such as those written in C/C++, Go,
Rust, etc. must define a
Makefile.uk which includes all relevant source files
of your application, e.g.:
$(eval $(call addlib,apphelloworld))APPHELLOWORLD_SRCS-y += $(APPHELLOWORLD_BASE)/main.c
Once your source files have been defined, it is simply a case of running the following to build your project:
Quickly switch between logging modes to get a better idea of what's happening under the hood by setting the following environmental variables:export KRAFTKIT_LOG_LEVEL=debugexport KRAFTKIT_LOG_TYPE=basic
Or by setting the equivalent command-line flags.
kraft --log-level=debug --log-type=basic build
Feel free to ask questions, report issues, and meet new people.