Running a Kubernetes Cluster at Home for Fun
This weekend, I set up a Kubernetes cluster at home with some old laptops just for fun.
|
| जुगाड़ until I buy or build a proper vertical stand for these laptops |
I used:
- Tailscale to enable the nodes to talk to each other
- K3s for setting up a K8s cluster
- Longhorn for replicated persistent storage
- The Tailscale Kubernetes operator to expose K8s services on my tailnet
- Helm charts to manage all deployments.
Some random details
- The cluster only has two nodes for now (
mavrosandluna), both running Linux.
Output of the kubectl get nodescommand - I reduced the default replica count from
3to1for the Longhorn storage class. I don’t really need high availability for most data at this point and I will manually increase the number of replicas for any volume that’s important to me.
A screenshot of the Longhorn dashboard - As of writing this post, I’ve only deployed Gitea (an open-source git-based code-hosting server) to the cluster.
I’ve pushed my ledger repository and a repository containing helm charts and values for this homelab project to the instance.
A screenshot of the Gitea "Explore" page - I’m trying to not make any changes to the templates of the helm charts that I’m using to keep the upgrade process as painless as possible.
For example: one way of exposing K8s services as devices on your tailnet is to change the service type toLoadBalancerand set theloadBalancerClasstotailscale. While most helm charts allow setting the service type toLoadBalancervia helm values, they do not allow setting aloadBalancerClassfor these services. I was initially patching the service templates in these charts to allow specifying aloadBalancerClass.
However, I later learned that the Tailscale Kubernetes operator also supports exposing services by setting a value for theingressClassNameonIngressresources. Most charts that create services usually also contain templates to createIngressresources for these services, and setting a value for theingressClassNameis much more common than setting aloadBalancerClass.
Hence, so far, exposing services usingIngressinstead of a tailscaleLoadBalancerhas allowed me to keep using upstream charts with custom values files.
Some things I’ll think about later
- I want to measure the electricity consumption of the laptops, to get a rough estimate of how much this setup costs in terms of energy usage.
- Both the nodes are currently using their 500GB internal drives for storage. While I don’t think I’m going to need a lot of space in this cluster anytime soon, it would be good to think about a plan to add storage to this cluster easily.