Kubernetes and CI/CD — How to integrate in your development process
By: Joerg Flade
Tags: Jenkins, Concept, Ci Cd Pipeline, Helm, Kubernetes

To define the Helmfiles configuration for all stages, the repository of the Helmfiles can have branches for each environment with an initial “develop” branch to update the Helmfiles.

To bring the changes to a stage, for example a Pull Request is required from develop to the “dev-stage” branch. If this was reviewed and approved, the changes can be merged to the “dev-stage” (and maybe trigger a deployment).

If we now create branches for all stages and merge changes to all of them, it is possible, for example, to change version numbers in the QA branch to be able to test special versions independently of the other branches.

You can also use multiple repositories for each stage and merge changes via upstream or pull requests. For example, if developers had added a new configuration value, they can create a PR to the other branches, making the change visible to other stages.

Links to an example

To see how it can work, you can have a look into those repositories, which provide a nearly full working example for everyone. The only thing, which is not working for everybody out of the box, is the docker push command in the Jenkins pipeline. The simple reason for that is, that I use here my own repositories and I don’t want to commit my tokens ;).

Because of the lack of an Artifactory server or something similar, I decided to create as much in Github as possible (like Helm repository), to make it transparent, how it looks finally.

K8S-JCasC-Management tool for easy deployment of Jenkins: https://github.com/Ragin-LundF/k8s-jcasc-management-go

K8S-JCasC-Management example repository for projects and Jenkins configuration: https://github.com/Ragin-LundF/k8s-jcasc-mgmt-example

The used containers (and their Dockerfiles) based on RedHat UBI images: https://github.com/Ragin-LundF/k8s-jenkins-docker

Example application, which contains a Gradle build, a NodeJS action and the Helm Charts: https://github.com/Ragin-LundF/k8s-jcasc-app-example

Helm Chart repository (upload of the Chart of the App): https://github.com/Ragin-LundF/k8s-jcasc-app-helm-charts

Helmfile deployment repository for the different stages/branches: https://github.com/Ragin-LundF/k8s-jcasc-deploy-helmfile-example

Last words

If you’ve read the whole story, I want to thank you for your patience and hope some things were helpful.

It may be impossible for you to build a similar environment due to business organization, other requirements, or some missing pieces.

However, it may already help to think about ways to use Kubernetes and how configuration-as-code and infrastructure-as-code can help secure the systems you need and how very high automation together with namespaces can open up possibilities that would be unthinkable in classic environments.

Alternative CI/CD tools for Kubernetes

This section is a short add-on with some links to other Kubernetes native CI/CD tools.

Depending on your requirements, it may make more sense to look at optimized tools. They all have some differences and work more like Bitbucket Pipelines or GitHub Actions.

The following tools are not cloud tools and can be used with your own infrastructure: