Running urunc with kind (Kubernetes in Docker)🔗
This tutorial sets up urunc in a kind (Kubernetes in Docker) cluster and deploys a test NGINX unikernel.
Prerequisites🔗
- Tools: Docker Engine,
kindandkubectl. - Host: An x86_64 host with KVM. The NGINX unikernel of this tutorial is built for x86_64 and runs on Qemu with KVM.
Overview🔗
kind runs each Kubernetes node as a Docker container. This tutorial creates a cluster with a single node, which has access to the KVM device of the host. Then, urunc-deploy installs urunc and its monitors in the node and adds urunc as a runtime of containerd. Finally, an NGINX unikernel runs as a Pod with the urunc RuntimeClass and replies to a request from the host.
Steps🔗
Step 0: Check KVM support🔗
Check that the host provides /dev/kvm:
If the device does not exist, enable virtualization in the BIOS and load the kvm_intel or kvm_amd kernel module.
Step 1: Create a kind cluster with KVM access🔗
-
Delete any existing cluster with the same name:
-
Create kind-config.yaml:
cat <<EOF | tee kind-config.yaml kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane extraMounts: - hostPath: /dev/kvm containerPath: /dev/kvm extraPortMappings: - containerPort: 30080 hostPort: 8080 listenAddress: "127.0.0.1" protocol: TCP EOFThe mount gives the node access to KVM. The node runs in a Docker container, so the host cannot reach its Pods directly. Therefore, the port mapping exposes port
30080of the node as port8080of the host. -
Create the cluster:
-
Verify KVM access:
The output should be
/dev/kvm.
Step 2: Install urunc with urunc-deploy🔗
urunc-deploy is a DaemonSet that installs urunc and the supported monitors in each node. It also adds urunc as a runtime in the containerd configuration of the node and restarts containerd. More details are in the urunc-deploy section of the Kubernetes tutorial.
-
Create the RBAC of urunc-deploy:
-
Create the urunc-deploy DaemonSet:
-
Wait for the installation to finish:
When the installation finishes,
urunc-deploylabels the node withurunc.io/urunc-runtime=true: -
Create the urunc RuntimeClass:
Step 3: Deploy the NGINX unikernel🔗
-
Create the Pod:
cat <<EOF | tee nginx-urunc.yaml apiVersion: v1 kind: Pod metadata: name: nginx-urunc labels: run: nginx-urunc spec: runtimeClassName: urunc containers: - name: nginx image: harbor.nbfc.io/nubificus/urunc/nginx-qemu-unikraft-initrd:latest imagePullPolicy: Always ports: - containerPort: 80 protocol: TCP resources: requests: cpu: 10m EOF kubectl apply -f nginx-urunc.yaml -
Expose NGINX with a
NodePortService:The
nodePortmust match thecontainerPortof the port mapping in Step 1.
Step 4: Verify the deployment🔗
-
Wait for the Pod:
The output should be
pod/nginx-urunc condition met. -
Check the logs:
The logs of Unikraft should show NGINX starting without errors. The unikernel needs a few seconds to boot, so run the command again if the output is empty. The output should end with lines similar to:
Powered by o. .o _ _ __ _ Oo Oo ___ (_) | __ __ __ _ ' _) :_ oO oO ' _ `| | |/ / _)' _` | |_| _) oOo oOO| | | | | (| | | (_) | _) :_ OoOoO ._, ._:_:_,\_._, .__,_:_, \___) Epimetheus 0.12.0~4c7352c0-custom [ 1.690891] Info: [libukboot] <boot.c @ 348> Pre-init table at 0x29f0d8 - 0x29f0d8 [ 1.722938] Info: [libukboot] <boot.c @ 359> Constructor table at 0x29f0d8 - 0x29f0d8 [ 1.751149] Info: [libukboot] <boot.c @ 369> Calling main(3, ['/cntrRootfs/unikernel/app-nginx_kvm-x86_64', '-c', '/nginx/conf/nginx.conf']) -
Send a request to NGINX:
The request goes through the port mapping of Step 1:
The output should be the page that NGINX serves:
Step 5: Clean up🔗
Delete the cluster, along with urunc and the NGINX Pod: