The goal of this demo is to demonstrate how to implement CICD workflow with image update automation for a CRD (HelmRelease).
We will be using:
- Kpack – for continuous integration
- Flux V2 – for continuous delivery
Kpack
a Kubernetes-native build service that builds container images on Kubernetes using Cloud Native Buildpacks.
It takes source code repositories (like GitHub
), builds the code into a container image, and uploads it to the container registry of your choice.
- No Dockerfile - Kpack builds OCI-compliant containers directly from source code, eliminating the need for developers to build and maintain dockerfiles.
- Manage image build process – build and push to image repository.
- Manage image updates - detects changes to source code, dependency, or OS components and automatically updates containers.
Flux
is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy.Flux
is Based on a set of Kubernetes API extensions (CRDs) which control how git repositories and other sources of configuration (like helm repositories) are synced into the cluster.
- Just push to Git and Flux does the rest - enables continuous application deployment (CD) through automatic reconciliation.
- Provides GitOps for both apps and infrastructure - can also manage any Kubernetes resource.
- Automatic image update – Flux V2 can even push back to
Git
with automated container image updates, deploy those changes, and keep your deployments and CRDs up-to-date.
What I used is in (parenthesis
)
- Running Kubernetes cluster (
minikube version: v1.25.2
) - Running Docker (
Docker version 20.10.16
)
- Write simplistic Java code and push to git (
Spring-Boot
) - After the code is pushed to git, build the code to an image with
Kpack
and push it to an image repository (DockerHub
) - Create a helm chart to deploy the application, and put in helm repository (
ChartMuseum
) - Configure Flux to update the helm repository and deploy the application automatically once there is a new image in the repository.
I implemented a simple SpringBoot web app with a 'Hello World!
' page, starting up on http://localhost:8080/
git clone https://github.com/GuyBalmas/example-app.git
delete the .git
folder and push the repo to your GitHub
Follow the Kpack
README.md at:
kpack-flux-demo/kpack/README.md
#or
https://github.com/GuyBalmas/kpack-flux-demo/blob/main/kpack/README.md
I implemented a helm chart for the example-app
SpringBoot web app, and it exists in its repo.
https://github.com/GuyBalmas/example-app/tree/main/chart
Follow the Install ChartMuseum
section of the Kpack
README.md:
kpack-flux-demo/kpack/README.md
#or
https://github.com/GuyBalmas/kpack-flux-demo/blob/main/kpack/README.md#install-chartmuseum
Follow the Flux
README.md at:
kpack-flux-demo/flux/README.md
#or
https://github.com/GuyBalmas/kpack-flux-demo/blob/main/flux/README.md