I’ve been trying to figure out a simple way to have a CI/CD pipeline for my personal projects. I’ve tried several options but was never happy with anything. The last attempt is to use a local microk8s cluster with production ready configuration and certificate management so I can easily deploy any project to the cluster without much work. This is the setup I ended up with.
There are 3 main pieces to this: Github actions, a docker registry and the kubernetes cluster itself.
On a home server I’m running a docker registry only accessible through the local network and also a github actions runner.
On the same server I’m running a single node microk8s cluster with the following addons:
- cert-manager - Letsencrypt Certificates Issuer
- ingress - Nginx Ingress provider
- dns - CoreDNS for cluster resolution on names
- dashboard - Kubernetes dashboard for easy visualization of resources
- host-access - Make the cluster bind to the server’s network IP (instead of its own IP)
With all of this setup the only thing missing is getting the project onto the cluster. Github Actions will take care of that. In summary the actions we need to run are:
- build docker image
- push to registry
- install helm chart (in project folders)
The helm chart has 3 Kubernetes resources: Deployment, Service and Ingress.
The final step will be to take care of the PersistentVolume
for a database. Will probably need the hostpath-storage microk8s addon.