Earlier this year I started consolidating some workloads to my homelab Kubernetes cluster. One of the last ones was a doozy. It's not a compute-hard or a memory-hard workload, it's a storage-hard workload. I needed to move the DJ set recording bot for an online radio station off of its current cloud and onto my homelab, but I still wanted the benefits of the cloud such as no thinking remote backups.
This bot has been running for a decade and the dataset well predates that, over 675 Gi of DJ sets, including ones that were thought to be lost media. Each of these sets is a 320 KiB/sec MP3 file that is anywhere from 150 to 500 MB, with smaller text files alongside them.
Needless to say, this dataset is very important to me. The community behind this radio station is how I've met some of my closest friends. I want to make sure that it's backed up and available for anyone that wants to go back and listen to the older sets. I want to preserve these files and not just dump them in an Archive bucket or something that would make it hard or slow to access them. I want these to be easily accessible to help preserve the work that goes into live music performances.
Here's how I did it and made it easy with Tigris.
An extreme close-up of a tiger with blue and orange fur. The Kubernetes logo replaces its iris.
Storage in my homelab
For your convenience when reading, Kubernetes terms are written in GoPublicCase.
If you want to learn more about a Kubernetes term, I suggest searching for
site:kubernetes.io TermNameHere
. All units are
Kubernetes units
when possible.
Kubernetes workloads are stateless by default. This lets you represent a lot of valid services (it's kinda like Heroku by default), but many times you will need persistent storage such as filesystem, relational, or object storage. In my homelab cluster, I have two StorageClasses: NFS mounting folders from my NAS (via the nfs-subdir-external-provisioner), and Longhorn. I ended up going object-storage native for this project so that I didn't have to worry about exhausting the storage on my homelab machines.
Most of my homelab projects use Longhorn for filesystem storage. Longhorn makes it easy for me to not have to care about rebooting my homelab machines, and when I do reboot one, it will automatically move volumes around so that they are local to the machine running a given workload. I also configured Longhorn to make nightly backups of all volumes to Tigris so that should my home get struck by a meteor, I would still have all of my data. Every volume is distibuted across three nodes, so random hardware failure is mathematically less likely to cause me to have to restore data from a backup.
I can't use Longhorn for this because the PersistentVolumeClaim would need to be at least one terabyte (1 Ti) and the primary SSD storage on each of my homelab machines is one terabyte for both the OS and other volumes. This is too big. I could add rotational drives to the mix in order to have more space (and I have since I did this), but I didn't have any free drives at the time. This data is also very infrequently accessed, so putting it on an SSD is overkill.
I could also put that data into my NAS via NFS, but I'd really feel better if that data was automatically backed up to the cloud (or already in the cloud to begin with). I could configure something to do that with a CronJob and a Tigris access key, but that would require extra configuration and seems kinda hacky. I'd really rather it be done by default or without extra configuration, following the Charmin Ultra rule of infrastructure complexity: less is more. The thing you don't need to go out of your way to configure is the thing that you will actually use.
I needed an option that would allow me to store the data in the cloud by default without changing the application code too much. The bot is currently written assuming that it's writing directly to a filesystem, kinda like most of the AI tooling you'll find in the wild. I could change it to write to an S3 bucket, but this bot was written before I believed Our Lord and Savior Unit Tests. I'd rather not mess with it if I don't have to.