Building images from a standard Dockerfile typically relies upon interactive access to a Docker daemon, which requires root access on your machine to run. This can make it difficult to build container images in environments that can’t easily or securely expose their Docker daemons, such as Kubernetes clusters (for more about this, check out the 16th oldest open Kubernetes issue).
To overcome these challenges, kaniko is introduced, an open-source tool for building container images from a Dockerfile even without privileged root access. With kaniko, we both build an image from a Dockerfile and push it to a registry. Since it doesn’t require any special privileges or permissions, you can run kaniko in a standard Kubernetes cluster, Google Kubernetes Engine, or in any environment that can’t have access to privileges or a Docker daemon.
In this blog, we will try building Docker images with Jenkins using Kubernetes as a build agent.
For this demo create a Kubernetes cluster using any of the cloud providers(GKE, EKS, AKS) or with minikube so we can install and configure Jenkins on the cluster so the dynamic kubernetes pod build agent can be used.
Also, the Artifactory instance is up and running so that we can pull/push docker images to the Docker repository.