I recently decided that my goal of creating and managing a kubernetes cluster to understand better how it works and what is happening under the hood had been realised, as my site had been successfully running on a cluster for a good while with no downtime, including during updates on Kubernetes from 1.15.X to 1.17.X.

As such I decided to look at what I can do to lower the management cost (time) and the hosting cost (money). In addition to this I have added a web interface (using Go Buffalo) to the backend service that uses PostgreSQL to manage the metadata rather than Google Cloud Firestore. So I needed a way to run PostgreSQL that I could trust.

This lead me to the question of wether I want to continue using Kubernetes or find an alternative.

  • If yes then is there a better way to host kubernetes, i.e. Are there any managed services that are cost effective? Any kubernetes flavours designed for edge computing etc.
  • If no, then what are my alternatives, i.e. Do I still use docker, or use docker swarm? Do I run Postgresql on the same host? etc.

Managed Services#

Looking at the big three’s (GCP, Azure and AWS) Kubernetes offerings I quickly ruled them out on a cost basis. I then looked in to the server providers that I considered for the original architecture (Hetzner, Scaleway and Digital Ocean). Scaleway and Digital Ocean have both released a managed Kubernetes offering.

I gave both a try and whilst Digital Ocean was a great experience, I cannot afford the monthly cost. Scaleway was a lot better on pricing, however, I had a terrible experience with them.

Locked my account for “spam”, refused to give any information as to what caused it to be classed as spam, and continued to take money out of my account for a load balancer that wasn’t connected to anything and couldn’t be turned off as I was locked out!

Traditional Hosting#

Starting to look at traditional hosting led me to spin up some VMs on my desktop, install Ubuntu server, and try to replicate what I had in my cluster. This was time consuming and I didn’t like it at all!

The realisation of how many abstractions I took for granted when using Kubernetes was massive. Installing postgresql was a breeze, but plumbing Nginx for Dev / Prod and changes to the pipeline to get automatic deployments was not fun at all, mainly due to the fact that they had been built with the goal of running in containers from the start.

At this point I had decided that the applications would need to be in Docker containers for my own sanity, and I just needed a way to run them.

I should have evaluated docker swarm as it covers the automation of running the containers, and shouldn’t be too difficult to set up. However, it would contain changes to the DevOps pipelines and learning how to use docker swarm (which is not a bad thing, just low on time).

Solution#

As I realised how much I enjoyed using Kubernetes for my personal projects, but don’t have the funds to use a managed service, I looked at using Microk8s, Ubuntu’s single node lightweight Kubernetes. Microk8s has a lot of OOTB features such as Ingress, DNS, Metrics, Storage and the Dashboard, meaning I can quickly get up and running. I have a lot of experience with Microk8s as I have used it for development for a while now. All of my YAML manifests still work (Nginx ingress, default storage, etc.) as well as the DevOps pipelines once given a new service connection. This effectively took me from 3 servers, where only two were used for compute power, to 1 server that was the entire Kubernetes environment.

One change I did make was that I preferred to keep Postgresql on the host itself rather than in the cluster. I will do a turorial soon on how to connect Microk8s to a Postgresql instance on the host.

Napkin Sketch
Updated Sketch