Getting Started with k0s and libvirt

Getting Started with k0s and libvirt

This example shows how to create a single-node k0s cluster in a local VM using Terraform and libvirt. The boundless-operator may then be installed.

Prerequisites

Along with boundless CLI, you will also need the following tools installed:

You will also need an SSH key for authentication with the created VM.

Create virtual machines

Creating virtual machines can be done using the example Terraform scripts.

After copying the example TF scripts to your local machine, you can create the VMs with the following steps:

  1. Create a terraform.tfvars file with content similar to:
cluster_name = "boundless-cluster"
cores = 2
mem_size = "2048"
disk_size = 20
user_account = "user"
ssh_public_key = "ssh-rsa AAAEXAMPLE user@example.com"
ssh_key_path = "/home/user/.ssh/id_rsa"
  1. terraform init
  2. terraform plan
  3. terraform apply
  4. terraform output --raw k0s_cluster > cluster.yaml

To get detailed information about the created VMs, you can use virsh:

virsh machine list

Install Boundless Operator on k0s

  1. Verify or edit the blueprint created in the previous step, cluster.yaml

  2. Create the cluster:

bctl apply -f cluster.yaml

Note: bctl apply adds kube config context to default location and sets it as the current context

  1. Update the cluster by modifying cluster.yaml and then running:
bctl update -f cluster.yaml
  1. Monitor the status of the cluster’s Kubernetes pods with:
watch -n 1 kubectl get pods --all-namespaces

Accessing the cluster

The example app addon can now be accessed through the http://<vm-node-ip>:6443 URL.

Cleanup

Delete the cluster:

bctl reset -f cluster.yaml

Delete virtual machines by changing to the example TF folder and running:

terraform destroy