Use Longhorn with Talos 1.10 and userVolumes
2025-06-17
When building a cluster, especially in a homelab, local storage is needed for application data. Especially for databases fast read and write is required. Offloading the workload to a NAS most of the time is slower. The solution I use is to provision on-node storage with Longhorn. Longhorn acts as a CSI and offers on-node storage, replication, backups and more.
As I am currently building a Talos cluster I need to integrate the longhorn CSI into the setup. This is not as straigt forward as with K3s oder K8s, as Talos has tighter security constraints and also needs additional plugins to handle SCSI - the underlying file system protocol used by longhorn. On top I am using Talhelper to allow a GitOps style usage of talosctl. The main advantage is the encryption of secrets used by talos config files with SOPS - something that I already use for Tofu and fluxCD.
In this article I use Talos 1.10, Longhorn 1.9 and Proxmox 8.4 as the hypervisor to provision the VMs.
Setting up a VM with Proxmox
I’m running my kubernetes cluster inside a Proxmox host. To streamline the hosting process I am using a terraform script to create the virtual machines. For Proxmox there are several providers, and the most complete one is bpg/terraform-provider-proxmox.
The talos images was derived from the Talos factory and uses the following plugins to enable longhorn prerequisites:
- siderolabs/iscsi-tools
- siderolabs/util-linux-tools
The tofu file creates a Talos worker VM with 2 disks. Disk one is the install disk, and disk 2 is for storing longhorn data exclusively.
|
|
Enabling iothread should give us an advantage when running database workloads in parallel on the cluster.
Configuring Talos with Talhelper
[Talhelper] is used to automate the process of secret encryption for the installation
|
|
- Talos is installed on vda
- UserVolume ’longhorn’ will be using disk vdb
UserVolumes are mounted by Talos during the setup stage of the node and are automatically placed under /var/mnt/{name}. Hence our longhorn mountpoint will be /usr/mnt/longhorn and will point to /dev/vdb. Now we have to allow the kubelet to access the mountpoint inside the containers:
|
|
This patch mounts the respective volumen provisioned by talos to be accessible by the kubelet. Hence longhorn is able to access the mounted volume that is configured. Now the only thing thats left is configuring lonhgorn.
Configuring Longhorn
In my cluster, longhorn is automatically installed by fluxCD. The longhorn install is covered by the helm controller, hence this install can also be perfromed manually using helm CLI.
|
|
If you are using longhorn on Talos, you also have to adjust the security policiy of the longhorn namepsace:
|
|
This allows the privileged execution of the longhorn manager (to use host binds for example). Without the annotations, the installation of longhorn will fail.
Bonus: Creating an encrypted StorageClass
Now that we have storage, I want to encrypt the data at rest to increase the security of the system. The required config is done with a StorageClass resource:
|
|
To create a pvc using the StorageClass, just reference it in your PVC and create a secret:
|
|
In the same namespace we need a secret as the previously defined StorageClass definition. The name of the secret follows the scheme ‘{pvc.name}-longhorn’ and for our pvc with the name ‘config’ the secret looks like this:
|
|
stat /posts/longhorn_uservolumes_talos/
2025-06-17: Initial publication of the article2025-07-06: Add remark on longhorn namespace requirements