K8s Continuous Delivery with FluxCD

Priyankar Prasad
3 min readNov 2, 2021

--

Flux is a tool which we can utilize to automate the deployments of the applications with the help of Git repository. In this article, I’m going to explain how to deploy Flux and Helm Operator, then how to integrate that with a GitHub repository. Finally I’m going to deploy few basic components in an EKS cluster by creating the correct manifest files.

Overall Workflow

1st Step : Create a GitHub repository

2nd Step : Deploy Flux and Helm Operator in the K8s cluster

  • Create a separate namespace to deploy flux related components.
$ kubectl create ns flux-demo
namespace/flux-demo created
  • Add flux helm chart to the cluster
$ helm repo add fluxcd https://charts.fluxcd.io
"fluxcd" has been added to your repositories
$ helm install flux-demo fluxcd/flux --set git.pollInterval=1m,git.url=git@github.com:prprasad2020/don-flux-repo.git,git.branch=main,sync.interval=1m,sync.timeout=5m,syncGarbageCollection.enabled=true -n flux-demo
Output of Helm Install
Deployed flux related pods
  • Generate a SSH key(fluxctl should be installed first) and add that to the Deploy keys(Settings > Deploy keys) of the GitHub repository. When adding the key, tick the “Allow write access” option also.
$ fluxctl identity --k8s-fwd-ns flux-demo
  • Install Helm Operator with helm version 3
$ helm install helm-operator-demo fluxcd/helm-operator --set helm.versions=v3 -n flux-demo
Output of Helm Install

3rd Step : Create manifest files for below components

Helm release manifest is created for deploying this component. I’m deploying this in an EKS cluster, so the cluster autoscaler version should be equivalent to K8s version.

Two Helm release manifest files are created for two ingress controllers. One is for external use and the other one is for internal use. When creating the ingress resources, ingress class can be used to select the ingress controller.

Helm release manifest is created for this component.

Helm release manifest is created for this along with the Cluster Issuers. More details on ACME issuers can be found here.

K8s manifest files are created for creating the namespaces for each component, other than the helm release manifest files. There are few parameters which I have removed in the manifest files, when configuring your components make sure to add the correct details/configurations.

4th Step : Commit/Push all the manifest files to the GitHub repository

If those are pushed to a separate branch, create a Pull Request and merge the changes to main/master branch. I’m using the GitHub Desktop application since it has all these features in the GUI. Once all the manifest files are merged to main branch, flux will identify those changes and deploy the components and create the namespaces according to the manifest files.

Deployed components in each namespaces

After correctly configuring the FluxCD, when there is a new release or when you want to update the version of an application, only thing you need to do is to change the manifest files and pushed those changes to the main branch of the GitHub repository. After that flux will identify the changes and deploy the applications with the latest updates.

--

--