Skip to main content
In this guide, you’ll create a Kubernetes cluster using KVM and virsh command-line utility.

Requirements

Make sure you have the following installed and configured:
  • Kernel with KVM enabled (/dev/kvm must exist)
  • QEMU
  • virsh: Command-line interface for managing KVM/QEMU VMs
  • kubectl: Kubernetes CLI
  • talosctl: CLI for interacting with Talos clusters
  • 16 GB RAM: Recommended minimum for running the VMs
  • (Optional) virt-manager for a graphical interface
Note: This guide assumes you are running all the commands from the following working directory.
Create a working directory for your project files:
Download the latest metal-amd64.iso from the Talos GitHub releases page.

Configure the network

Before we get started, let’s set up an isolated network for your Talos cluster. Use the following command to write the required network configuration into a file.
Use the following command to generate the configurations and define the bridge:
Use the following command to start the network and flag it to auto start after reboot:
Verify the network:
Note: You should see the network as Active.
Expected output:

Provisioning the environment

Now that you have a dedicated network let’s go ahead and provision VMs.
Note: For the network interface emulation, virtio and e1000 are supported. In the next command, you will use the --network network=my-talos-net flag to attach the VMs to the Talos network you created earlier. The values for —ram and —vcpus in this guide are suggestions. You can adjust these to match the resources available on your host machine and the needs of your workload.
Use the following command to create a controlplane node:
Use the following command to create a worker node:
Use the following command to verify that your VMs are in a running state:

Configure the cluster

Now that you have your VMs provisioned it’s time to configure the cluster. This step is done through talosctl command utility. Use the following command to view your control plane IP address, and do the same for your worker node by adjusting the vm name:
This guide is designed to help you get up and running quickly. To simplify the process, you will store the VM IP addresses in two environment variables: CP_IP and NODE_IP. You can automate this step with the following commands:
Currently, your VMs are running Talos directly from the ISO image you downloaded. To install Talos onto the VM disks (so they can boot without the ISO), you need to specify the disk name during the configuration step. Use the following command to get the name of your VMs disk:
You should see a result similar to the following:
Use the following command to generate the Talos configurations:
Use the following command to apply the configurations to each VM:
At this point your VMs will reboot.

Bootstrapping the cluster

After your VMs restart, you can bootstrap the cluster. Bootstrap simply means starting up your Kubernetes cluster for the first time. To do this, provide the talosconfig file (generated earlier) to the talosctl command-line utility. The easiest way is to export the path to talosconfig as an environment variable. Use the following command to export your talosconfig:
Before running the bootstrap, you need to tell talosctl where to connect:
Note: Keep in mind that it may take a couple of seconds for the bootstraping to complete.
Use the following command to bootstrap the cluster:
At this point you should be able to see all the VMs that are participating in your cluster.

Accessing the cluster

To access your cluster you need to export the kubeconfig file from the Talos cluster. Use the following command to export the kubeconfig file:
Set the KUBECONFIG environment variable to use your new kubeconfig file.
That’s it! You can now use kubectl to interact with your Talos Kubernetes cluster. Check the status of your nodes with kubectl to verify they are ready.

Clean up

When you are finished with your cluster, you can delete the VMs and the isolated network to free up system resources.
Use the following command to delete the network: