I recently did some work on a fairly simple controller to run inside Kubernetes. It connects to the K8s API and watches for changes to
ingress objects in the cluster.
I had a nice cluster spun up for testing which I could tweak and poke then observe the results. This was nice BUT I wanted to translate it into something that ran as part of my CI process to make it more repeatable. Having not played much with the new Azure Pipelines I decided to try and get this working using one.
Here was the goal:
- Build the source for the controller
- Spin up a Kuberentes cluster
- Deploy test resources (Ingress and Services) into the cluster
- Connect the controller code to the cluster and run it’s tests
The obvious choice was to look at creating the clusters inside a cloud provider and using it for testing but I wanted each PR/Branch to be validated independently in a separate cluster, ideally in parallel, so things get complicated and expensive if we go down that route.
Instead I worked with MiniKube which has a ‘no vm mode’, this spins up a whole cluster using just docker containers. The theory was, if the CI supports running docker containers it should support MiniKube clusters…
TLDR: Yes this is possible with MiniKube and Azure Pipelines or Travis CI – Skip to the end to see how.