Why I switched to Kubernetes for running my Personal Side Projects
For the past few years, I've been running all of my low-traffic personal side projects on DigitalOcean's cloud-based virtual machines called Droplets as they're easy to set up, cost-effective and offer reliable uptime. The initial projects that I created were in PHP, the language that I started my programming journey with, and used MySQL for data persistence. NGINX was used as the reverse proxy server for exposing some of these projects to the web. Later I also started using Node.js and Python for the backend code and used both MySQL and MongoDB databases.
The infrastructure requirements for my personal projects kept changing with every new programming language (or a newer version of it) and using the same machine for running all of them together became more challenging. Not only was it a security nightmare to run outdated runtimes, but it was also challenging to remember all the changes I had done to the machines over the years. In spite of me trying to document everything, I would often break a service while trying to deploy another or upgrading the machine OS to a newer stable version. A service would go down and it would take me hours to figure out how it ran in the first place. Of course, all of the old code looked like spaghetti now.
Considering that these machines mainly hosted my side projects, I did not want to spend any extra time or money on moving them across multiple machines as that would've further added more maintenance work in the long run. I needed a solution that would allow me to run all of my projects in isolated environments without needing me to worry about maintaining the infrastructure or something old going down because I tried to deploy something new. While services like Heroku and Vercel seemed enticing, I wanted a solution which gave me full control over the machine and allowed me to make any infrastructure changes based on my needs. As I had already been using Docker and Kubernetes for work at that time, I knew that it can solve most of my problems and also provide me an environment to try out new stuff. But setting up and maintaining a Kubernetes cluster for personal projects again felt like a lot of hassle and the managed K8s offerings like GKE and EKS charged a bomb! Thankfully DigitalOcean also started offering Managed Kubernetes service in late 2018 and that's when I decided to finally take the plunge.
Over the course of a few weeks, I gradually made code changes and dockerized majority of the projects. I had let go of a few of them as they way too old and would've almost required a complete rewrite (They were in PHP 5 which has already reached the end of life). I created a new single-node based managed Kubernetes cluster on DigitalOcean, attached a Load Balancer to it and moved the projects there. As all of these projects were hosted on Gitlab which offers a free Docker Registry and free CI/CD minutes, I used it to build the Docker images and deploy them on the Kubernetes cluster. Thanks to free SSL certificates provided by Let's Encrypt, all of my projects now run on HTTPS.
It's been over a year since I did this migration and everything has been running smoothly so far. I've upgraded the cluster to newer versions a couple of times without having to do any code changes.