Creating a Kubernetes cluster using Talos Linux on Xen Orchestra

Talos Linux is an OS built to run Kubernetes clusters. There is no SSH, everything is controlled via an API. My homelab runs Xen Orchestra, looking at the instructions there is no guide for Xen Orchestra, so being someone who loves a challenge, I thought it would be good to try and set this up and see how we get on.

Step 1 is to download the ISO. I’m on AMD so I grabbed the metal-amd64.iso from the releases page. The next step is to upload the ISO to my Xen Orchestra ISO repository. For details on how to create an ISO repository if you don’t have one check out this article.

With the ISO setup, the first step is to create a new VM to be our control plane node. For this cluster I’m only going to have a single control plane node to keep things simple. Click on new VM, then fill out as per the screenshot below:

The key parts to call out here is you want to use a template that is compatible that allows you to set an ISO such as Ubuntu Focal Fossa 20.04. I set the machine name to Talos Control Plane, vCPUs and RAM will be dependent on what you have available.

Once the machine boots, go to the console in Xen Orchestra and read the IP address from the screen. The thing that caught me out when I was researching for this blog post, was that every time the machine restarts it changes its IP address. Given that in our setup we are going to use a static IP for our control plane node, this is not going to work for us.

To solve this problem go to the console of the Talos Control Plane VM in Xen Orchestra and press F3 to get to the network settings. Press tab until you get to the interface, change it to the one with a name starting enx followed by some random characters. Set mode to Static, DHCP means it will change each reboot. Set the addresses field to the IP address you read from the main screen and then the CIDR for your network, so for me I’m using a 192.168.1.0/24 network and the IP the machine got given was 192.168.1.44, so I set the addresses field to 192.168.1.44/24. Then set the gateway to the IP address of your gateway, for me that’s 192.168.1.1. Save the configuration.

To configure talos you can use the command line tool talosctl, to install:

curl -sL https://talos.dev/install | sh

Once installed set CONTROL_PLANE_IP on your command line to the IP address of this VM and then run:

talosctl gen config talos-cluster https://$CONTROL_PLANE_IP:6443 --output-dir _out

This will generate a set of config files in the directory _out/. The disks by default will be incorrect in these template files for use with Xen Orchestra. Find out the disk paths of your machine by running:

talosctl disks --insecure --nodes $CONTROL_PLANE_IP

Replace the disk property inside the controlplane.yaml and worker.yaml with your disk path, for me its /dev/xvda and then save the files. Your yaml in those files should look like:

    install:
        disk: /dev/xvda # The disk used for installations.

With that in place you are now ready to bring up the control plane node. To do that run the following command:

talosctl apply-config --insecure --nodes $CONTROL_PLANE_IP --file _out/controlplane.yaml

Once you run this command, the control plane VM will stop. Go to Xen Orchestra and start it again, then if you watch the console you should see it start. Once its up you are ready to bootstrap the cluster, which will start etcd and get Kubernetes actually running.

To use the cluster its easier to setup the talos config using these comamnds:

export TALOSCONFIG="_out/talosconfig"

talosctl config endpoint $CONTROL_PLANE_IP

talosctl config node $CONTROL_PLANE_IP

With that setup bootstrap the cluster using:

talosctl bootstrap

Once you have run the bootstrap command, if you view the console of the control plane VM in the Xen Orchestra, you can slowly watch all of the health checks go green. When that happens the cluster is up and cooking:

Now you can use the cluster from the command line, to retrieve the kubeconfig run:

talosctl kubeconfig .

Which will copy the kubeconfig locally, you can run a test to see if you can query your new cluster with kubectl using:

kubectl get nodes --kubeconfig=./kubeconfig

That should return your lone control plane node. In order to add some worker nodes, follow the steps above for adding another VM, don’t forget to set the IP address to be static. Then with the new VM ready run the following command to make it a worker in your cluster:

talosctl apply-config --insecure --nodes $WORKER_IP --file _out/worker.yaml

After you run this command the VM will stop, so you need to start it in Xen Orchestra. Once its started you should see it spin up and join the cluster.

For my cluster I added another worker node and everything is working perfectly.

I’m super impressed with my first impressions of Talos OS. Does a lot of heavy lifting to setup Kubernetes clusters for you. It is simple to use and I got the whole cluster setup in around 15 minutes from zero, which for anyone who has every provisioned clusters using kubectl is pretty good going.

Anyone looking for a good way to provision and run Kubernetes clusters on bare metal, definitely check out Talos OS.

Leave a Comment