Kubernetes
Unikraft Cloud integrates seamlessly with any Kubernetes cluster through a virtual kubelet known as Kraftlet. This is a lightweight Kubernetes node implementation which connects your cluster to Unikraft Cloud's high-performance compute instead of running real pods locally. This enables developers to deploy and manage Unikraft unikernels as if they were native Kubernetes pods.
This integration extends Kubernetes' scheduling and orchestration capabilities to the Unikraft Cloud platform. This allows workloads to take advantage of unikernel-level I/O performance, security, cold start and transparent scale-to-zero efficiency while retaining full compatibility with existing Kubernetes tooling.
Upon startup, Kraftlet will register itself as a worker node with the Kubernetes API. Once Kraftlet registers itself as a node, Kubernetes can schedule Pods onto it.
Any Pod scheduled to the Kraftlet node won't run as a container within the cluster. Instead, it will run a highly optimized, ultra lightweight unikernel VM instance on Unikraft Cloud. Kraftlet will manage the Pod lifecycle to make sure the apps are up and running.
Getting started
You can install Kraftlet into a Kubernetes cluster using its Helm chart:
(bash)
You can check if Kraftlet is running by checking its pods:
(bash)
Which should return a single pod running:
Code
You can also check if the kraftlet successfully registered as a node:
(bash)
Which should, among other nodes, return Kraftlet.
Code
Examples
Below are examples of Kubernetes configurations that define Unikraft Cloud apps through Kubernetes concepts.
You will notice that each workload object defines tolerations and nodeSelector so Pods get scheduled on the Kraftlet node.
Make sure Kraftlet is up and running before trying out examples below.
Simple app
The configuration below defines an app with three replicas running the nginx image and a single Kubernetes service that exposes port 443.
For each service backed by a Pod scheduled to the Kraftlet node, Kraftlet will create a corresponding service.
In this case, Kraftlet will create three nginx instances and a single service called after the Kubernetes service that exposes port 443.
Code(yaml)
You can apply the configuration with:
Code(shell)
Once applied, you can check the status of your newly created pods in the Kubernetes cluster:
Code
Your app is now managed from the Kubernetes cluster, but is actually running on the Unikraft Cloud.
To check the instances, run:
Code(shell)
Which will return a list of instances created from pods above:
Code
As you can see, all instances have the same FQDN. This is because Kraftlet created a corresponding Unikraft Cloud service for the Kubernetes service defined in YAML above. You can check the created service with the following command:
Code
You can now manage your app running in Unikraft Cloud via Kubernetes resources!
Stateful apps
The example below deploys a stateful app on the Unikraft Cloud that has access to a volume.
To support provisioning Unikraft Cloud volumes through Kubernetes, Kraftlet listens for changes on PersistentVolumeClaim (PVC) objects with storage class ukc-volume.
Creating a new PVC object with the specified storage class triggers Kraftlet to create a Unikraft Cloud volume and create a PV object to mark the PVC as Bound.
Below is an example PVC with the Unikraft Cloud storage class you can apply to your cluster.
Code(yaml)
Once applied, you can check the created PVC status:
Code
Also, you can check the volumes on the Unikraft Cloud:
Code
At the moment, the volume isn't attached or mounted by an instance. To create an instance that would use the volume, you can create a Kubernetes Pod that would reference the PVC:
Code(yaml)
If you check the instances again, you will see a new instance created from the Pod:
Code
And if you check the volume now, you will see it's attached and mounted by the created instance:
Code
Notes
-
For each Pod scheduled on Kraftlet, Kraftlet runs its containers as separate Unikraft Cloud instances rather than running them as containers. Kraftlet ensures it assigns instances to the correct Unikraft Cloud services and attaches them to the corresponding Unikraft Cloud volumes.
-
When a Pod gets scheduled on the Kraftlet node, Kraftlet fetches the existing Kubernetes service that the given Pod is backing and creates a corresponding Unikraft Cloud Service. Kraftlet allows cluster admins to manage Unikraft Cloud Services by defining a Kubernetes service backed by Pods running on Kraftlet.
-
Kraftlet listens for changes on PersistentVolumeClaim objects with storageClass
ukc-volume. For each creation of such Persistent Volume Claim (PVC) object, the Kraftlet will create a corresponding Unikraft Cloud volume and aPersistentVolumeobject to bind the PVC object to. Kraftlet allows for volume management through Kubernetes clusters.
Resources
- See Unikraft public roadmap for planned features or to suggest use cases and ideas.