Skip to content

Kubernetes & Crossplane

Deploying a Unikernel to KraftCloud with Crossplane

Crossplane operates as a Kubernetes add-on, turning it into a universal control plane that manages both cloud services and infrastructure. It introduces the concept of ‘Infrastructure as Code,’ enabling users to define and provision cloud resources using Kubernetes-style manifest files.

Installation and Configuration of the Crossplane Provider

Before You Begin:

  • Confirm administrative access to a Kubernetes cluster (can be a local one like Minikube).
  • Secure a token for the KraftCloud platform.
  • Choose a unikraft unikernel image, like nginx.
  • Ensure Crossplane and its CLI are installed in the cluster.

Installation Steps:

  • Install the provider: Deploy the KraftCloud provider using the command:
Terminal window
crossplane xpkg install provider --wait=1m
  • Authenticate the provider against KraftCloud:

Create a base64 encoded Secret in crossplane-system and apply a ProviderConfig that refers to this secret.

Paste a base64 encoded token into the credentials field in the YAML below.

Save them to a file named secret.yaml

apiVersion: v1
kind: Secret
namespace: crossplane-system
name: example-provider-secret
type: Opaque
credentials: #base64 encoded kraftcloud token
kind: ProviderConfig
name: example
source: Secret
namespace: crossplane-system
name: example-provider-secret
key: credentials

Then, simply run:

Terminal window
kubectl apply -f secret.yaml

Done! Your provider is now running and will be able to communicate with KraftCloud’s API.

Deploying a Unikernel Instance

If you’re eager to get started quickly, you can utilize our official nginx image, readily available for all users.

For those interested in custom solutions, you can still build and use your own images — see the Quick Start guide.

To deploy an nginx instance, ensure the provider is installed and running, then use the following YAML configuration:

kind: Instance
name: example
metro: fra0 # Here you control which metro the instance should be scheduled at
image: nginx:latest
memory: "64Mi"
- "-c"
- "/nginx/conf/nginx.conf"
internalPort: 8080
port: 443
desiredState: running # It's possible to create "stopped" instances.
name: example # Reference to pre-applied crossplane config containing your token

After applying this YAML, you will be able to list the instance via:

Terminal window
kubectl get instance

This will result in:

Terminal window
example True True ced7f992-5feb-4fb7-9d3e-e92886d8859f 27m

To get even more information, run:

Terminal window
kubectl describe instance example

The output of this command will contain various additional data, such as:

Terminal window
At Provider:
Boot Time: 7080
Created At: 2023-11-22T07:50:24Z
Private IP:
Last Transition Time: 2023-11-22T07:50:25Z
Reason: Available
Status: True
Type: Ready
Last Transition Time: 2023-11-22T07:50:24Z
Reason: ReconcileSuccess
Status: True
Type: Synced
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CreatedExternalResource 28m managed/ Successfully requested creation of external resource
Normal UpdatedExternalResource 11m (x4 over 14m) managed/ Successfully requested update of external resource

As you can see, one of the outputs is the DNS of the created instance. You can take that address and query it to confirm your instance is working properly:

Terminal window

To delete the instance, simply delete the kubernetes object. The crossplane provider will reconcile the state in KraftCloud and remove the instance for you:

Terminal window
kubectl delete instance example

Troubleshooting and FAQs

How to debug issues with the provider?

The first place to start is the log output of the running provider pod. Locate the pod and inspect its logs via:

Terminal window
kubectl logs -f kraftcloud-provider-pod-name -n crossplane-system

Create, delete or update the instance definition in the kubernetes cluster and look for errors in the log.

This workflow is also possible locally. If you are authenticated against a cluster with crossplane installed, check out the repo and run:

Terminal window
make submodules
make run

Before attempting the above, make sure the KraftCloud connection token has been applied to the cluster.

Which actions does the provider support?

In its present state (0.2.0), the provider allows creating, deleting, starting and stopping running unikernel instances.

How can I see the state of my deployments?

KraftCloud integrates with our kraftkit CLI. You will be able to see the instances created with crossplane by running:

Terminal window
KRAFTCLOUD_METRO=fra0 kraft cloud instance ls

For more information, please refer to kraftkit’s documentation. Footer