CICD, K8S, Gitlab, Kaniko — Container Builds on a private Kubernetes Cluster
Usually CI/CD jobs in Gitlab are executed on the shared runners. If you would like to run builds and CI/CD jobs on your own Kubernetes infrastructure, then today’s blog post is for you. We show how you can run container builds on the private Kubernetes cluster.
opensight.ch — roman hüsler
You can build Docker container images with the already very familiar “docker build” command. So you need an appropriate host where the Docker Engine and Command Line Tools are installed. However, what if you would like to run the builds on your existing Kubernetes cluster in a pod? This is what Kaniko is for and that’s what today’s blog post is about.
In a few steps we create a CI/CD pipeline on Gitlab, which should meet the following requirements or the project has the following properties:
- NodeJS project
- Google Container Registry
- Gitlab CI/CD Pipeline
- Gitlab Runner on our local Kubernetes cluster
- Docker builds are run on Kaniko’s own Kubernetes cluster
Of course, we hope that some of the processes described will also help you with your individual setup.
- We assume that you already have a NodeJS project (or similar) on Gitlab with which to do this setup.
- We assume that you already have a Kubernetes cluster and have configured the HELM CLI tool.
- We assume you already have a container registry, for example on Google Cloud
Setup Gitlab Runner
We don’t want our Gitlab CI/CD pipeline to run on a public node, but locally on our own Kubernetes cluster. Therefore we install a Gitlab Runner on the cluster.
The Gitlab runners are displayed in the Gitlab project under “Settings / CICD”. Also a registration token to register our local runner (oranged out), as well as instructions to…