My First Kubernetes App
With my docker VM, I used Docker Compose to deploy a multi container app. Now it’s time to level up and use Kubernetes.
Writing manifests for kubernetes is a lot more verbose than writing docker compose files. It’s more than what’s needed for local development but simple use cases are still fairly accessible to build.
The App
I have a reading tracker application I’ve built with the homelab practice in mind. It’s composed of:
- A React/Vite frontend,
- A Golang server,
- A PostgreSQL database,
- A Redis instance.
The frontend only talks to the server, and the server connects to both PostgreSQL and Redis.
I wrote a manifest for each part of this project, which is a big difference with the docker setup: Instead of 1 docker compose orchestrating the whole project, it’s deployed in 4 parts. This allow to scale each service depending on the needs while keeping the other small - and dealing with 1 database even if there’s 10 api replicas.
The Mistake
One mistake I did initially is that I didn’t version my containers with enough specificity. While I was building new api containers, my cluster was not pulling them. Because of that I was trying to solve a bug that was already solved. Once I sorted the version number usage, k3s picked up the proper up to date container.
What I learned
I did a few exercises to play around the project, one of them was to simulate a node needing a reboot. I used cordon and drain to move all the pods to the available nodes, then used uncordon before the next deployment and saw workloads going to that node again.
Summary
Now my app is working from kubernetes instead of the docker vm, but it still has ugly urls with NodePorts. My next learning step will be to setup ingress for the cluster.