I used to run from Kubernetes. Now, I'm hooked.
I somehow got it into my head to begin self-hosting on a laptop running k8s.
I was way in over my head, but I've learnt a lot in the past few weeks.
Background
For some context, I have used AWS, Azure, GCP, Cloudflare, and run my own VMs.
I wanted a simple server to host the backend for my mykeels.com website, and products like under4.games. I had an old laptop running Windows 10 that just gathering dust, and I'd learnt I can tunnel apps with Cloudflare Tunnel, so I wanted to see if I could run backend apps off it.
Why?
My needs were simple:
- deploy from my dev machine to the laptop server.
- see deployments, rollback when things go wrong.
- see logs, and debug when things go wrong.
- run the database on the server.
- replicate the database to a remote server.
I was looking for a simple heroku-like solution that was free, could run any app I threw at it, and was easy to setup. I can't remember exactly how the search went, but after looking at a bunch of tools, I ended up reading about how kubernetes could do all of these.
I was reluctant because I've always seen kubernetes as a complex tool that was difficult to maintain, so when I learnt that K8s can run on a laptop via K3s, I was intrigued. My understanding is kubernetes is an abstraction and there are many implementations of it, K3s being one of them. K3s is a lightweight kubernetes distribution that can run on my laptop.
How did it go?
Was it hard? Yes. I'd forgotten a lot about linux management from relying on managed services and cloud providers. Phew! But it was worth it.
I scrapped Windows 10 and installed Arch Linux running Omarchy as the desktop environment. It took a while to get everything working, and the sound still doesn't work, but the machine works enough for me to get by.
Kubernetes, it turns out, is like an entire cloud computing environment in a box. It has everything I wanted and more I can't even fathom right now, and the only entrance fee is a few hours of my time to learn how to use it.
What did I learn?
Oh I learnt and am still learning a lot. Such as:
StatefulSets are ideal for Databases running in K8s so the data can be persisted no matter how many times the pod is restarted. I was using Deployments like a rookie and wondering why my data was disappearing.
You can host your own docker registry. It's easy to do.
Kubernetes Lens is a good software for viewing k8s details.
Kubernetes seems to be an abstraction for cloud computing, and there are many implementations. I use K3s, an implementation which is light enough to run on a single machine.
Write stuff down. When setting up a machine, you will forget little things. It's important to maintain a notebook as you discover new things.
.NET Aspire + Aspirify is a great combo for describing systems and emitting k8s yaml artifacts. However emitted artifacts may need further transformation.
Cloudflare Tunnels are a great way to expose services to the internet.
What's next?
I'm going to keep exploring K8s and see what else I can do with it.
I'm also going to keep using .NET Aspire + Aspirify to describe systems and emit k8s yaml artifacts.
See you next time!