Life and Shell

Writing · kubernetes

My 128 GB, 12-core, 4 TB Kubernetes cluster for €45 a month, and you can build it yourself

By Mattias Hemmingsson · · 5 min read

I have a Kubernetes cluster with 128 GB of RAM, 12 cores and 4 TB of disk. It costs me about €45 a month.

It is not a managed service and there are no free credits behind it. It is two rented servers on Hetzner, and you can build the same thing in an evening.

What you get for the money

Part What Price per month
Control plane The smallest Hetzner Cloud server: 2 vCPU, 4 GB RAM about €5
Worker A metal server from the Hetzner server auction: 12 cores, 128 GB RAM, 2 × 2 TB disks (4 TB) about €40
Private network between them Hetzner vSwitch free
Load balancer None. The worker's public IP is the front door €0
Total about €45

Prices move, and the auction changes every hour, so treat the numbers as what I pay, not a quote.

Kubernetes itself reports 125 GB on the worker, because the system keeps a little of the 128 GB for itself.

The 4 TB is two separate 2 TB disks, not a mirror. Talos is installed on the first one, and the second one is given whole to Longhorn, so the cluster has 2 TB for persistent volumes.

Compare that with renting the same memory as cloud servers. A cloud server with 128 GB of RAM costs several times more than this whole cluster, at any provider I have looked at. The reason is simple: the auction servers are older hardware that Hetzner has already paid off, and they rent it out cheaply instead of scrapping it.

The idea

Most cheap Kubernetes setups put everything on one machine. I split it in two on purpose:

  • The control plane is small and lives in the cloud. It only runs etcd and the Kubernetes API. That needs very little, so the cheapest server is enough.
  • The worker is big and made of metal. All the pods run there. This is where you want the RAM and the cores, and metal is where they are cheap.
  • A vSwitch joins them. Hetzner connects a metal server to a cloud private network for free. The two servers talk on private addresses and the cluster traffic never crosses the internet.

The nice part of the split shows up on a bad day. If the metal server breaks, the control plane is still there with the whole cluster state. I fix or replace the worker, it joins again, and Kubernetes starts everything back up.

Both servers run Talos Linux, an operating system that does one thing: run Kubernetes. There is no SSH and no package manager. You describe the machine in a YAML file and send it over an API. That sounds strict, but it means there is nothing on the servers to patch by hand or to drift.

What runs on it

I installed the full platform I need, all from git through ArgoCD:

  • Cilium for the pod network
  • Traefik for ingress, on ports 80 and 443 of the worker
  • cert-manager with Let's Encrypt certificates
  • Longhorn for storage, on the second 2 TB disk
  • Prometheus and metrics-server
  • CloudNativePG for Postgres and an operator for MySQL

With all of that running, the worker uses 2% of its memory. The other 98% is for the things I actually want to run.

What it is not

I want to be straight about the limits, because this is where the price comes from.

  • It is not highly available. There is one worker. If its hardware fails, the workloads are down until it is fixed. The control plane is also a single node.
  • The disks are spinning disks. Fine for most apps, slow for a busy database. Auction servers with NVMe exist and cost a bit more.
  • You are the operations team. Nobody upgrades Kubernetes for you or calls you when a disk dies.
  • The hardware is used. That is why it is cheap. Hetzner replaces broken parts, but you should have backups somewhere else.

For side projects, internal tools, CI runners, staging environments and learning, I accept all of that gladly. For a service where an hour of downtime costs real money, add a second worker and a second and third control plane node, and it is still cheap.

Build it yourself in five steps

  1. Rent the two servers. Order the smallest cloud server in the Hetzner Cloud Console. Then go to the server auction, filter on RAM and sort by price. Pick a location in the same network zone as the cloud server.
  2. Connect them. Create a vSwitch in Hetzner Robot and add the metal server. Create a private network in the cloud project with one subnet for cloud servers and one for the vSwitch.
  3. Put Talos on both. Boot each server into Hetzner's rescue system, log in with SSH and write the Talos disk image straight onto the disk with dd. Reboot.
  4. Send the config. Generate the Talos config, add the private network settings for each machine, apply it, and bootstrap the cluster with one command.
  5. Add the pod network. Install Cilium with Helm. Both nodes turn Ready, and you have a cluster.

Each step has a detail or two that will cost you an hour if nobody tells you: the metal server needs a tagged VLAN and a route, the vSwitch has a smaller packet size than normal, and disks change names between the rescue system and Talos.

I wrote all of it down, with every command, the config files and a network diagram, in the full guide:

A cheap, powerful Kubernetes cluster on Hetzner: €5 cloud control plane, auction metal worker, Talos

Tips for the auction

  • Filter on RAM first. Memory is what Kubernetes workloads run out of. Cores are rarely the limit for small services.
  • Two disks are useful. One for the operating system, one whole disk for storage.
  • Check the location. The vSwitch only connects to a cloud network in the same network zone.
  • Do not wait for the perfect box. The list changes all the time and good ones go quickly. You can cancel a server monthly and take a better one later, and with this setup, moving to a new worker is just joining a new node.

Would I do it again

Yes. I moved to this from a single 4 GB cloud server that kept running out of memory, and for about €40 more a month I went from 4 GB of RAM and 76 GB of disk to 128 GB and 4 TB.

If you have been holding back on running your own cluster because of the cloud bill, this is the cheapest serious way I know to start.

Filed underkubernetes · hetzner · talos · homelab · devops · cost