Home  > Resources  > Blog

Introduction to Flux

November 28, 2022 by Bibhas Bhattacharya
Category: DevOps

1.1 What is Flux?

Flux is a tool that helps you adopt GitOps operations in a Kubernetes cluster.

  • Web site: https://fluxcd.io/
  • GitHub repo: https://github.com/fluxcd/flux2
  • It is written in Go.
  • A project supported by Cloud Native Computing Foundation https://www.cncf.io/

1.2 Key Components of Flux

Sources – A source represents a Git repository. It is defined in a YAML file using custom K8s resources like GitRepository and HelmRepository. You store K8s manifest YAML files in these repos. Flux can continuously monitor such a repo for any changes. Alternatively, you can use web hooks to notify Flux when something changes in the repo.

Reconciliation – This is the process of synchronizing a K8s cluster configuration with the desired configuration in the source repos.
Kustomization – Every application provide its own specific set of manifest YAML files. For example, the Docker image name, port number and the number of replicas to be used for the application. Kustomization files are also stored in Git repos.

Bootstrap – This is the one-time process of installing and setting up Flux.

1.3 Installing Flux

 In your administration machine log into K8s and obtain a token.
 Install flux command line:
◊ Linux: curl -s https://fluxcd.io/install.sh | sudo bash.
◊ Mac: brew install fluxcd/tap/flux
 Verify that Flux is installed.
flux –version
 Run this command to check all prerequisites for Flux.
flux check –pre

1.4 Bootstrapping Flux

 Bootstrapping does two things:
◊ Installs various components of Flux as deployments and services in the K8s cluster. These components make up the actual runtime of Flux.
◊ Creates a Git repo and stores the manifest YAML files used to define the above resources.
 Export two shell variables to supply your Git authentication. If using GitHub use your Personal Access Token (PAT).
 Run the bootstrap command. The switches are described in the next slide.
flux bootstrap github \
–owner=$GITHUB_USER \
–repository=flux-documents \
–branch=main \
–path=./clusters/my-cluster \

1.5 Bootstrap Switches

  • owner – GitHub user ID.
  • repository – The name of the repo that will be created.
  • branch – The branch where the manifest files will be added.
  • path – The folder in which the manifest files will be added. You can use a
  • single monorepo to store files for several clusters.
  • personal – A private repo will be created.

1.6 A Review of the Components

All components are created in the flux-system namespace.
If you run this command you will see all the deployments made by bootstrap.
kubectl get deployments -n flux-system

An explanation of the components.

  • source-controller – Responsible for interacting with Git and Helm repo to pull or push files.
  • kustomize-controller – Constantly monitors Git repo and looks for changes. If changes are detected then the modified files are pulled and the changes are reconciled with the cluster.
  • notification-controller – Can receive webhook events from a Git repo. This webhook option, if configured, can be more efficient than the kustomize-controller periodically polling the Git server.
  • helm-controller – Manages Helm chart releases with Kubernetes manifests.

1.7 Manifest Files Created by Bootstrap

The components discussed above are defined using a set of YAML manifest files. These files are committed to the GitHub repo created by the bootstrap process.
◊ gotk-components.yaml
◊ gotk-sync.yaml

1.8 Summary

 Flux is a tool to implement GitOps practices.
 After Flux is installed it needs to be bootstrapped.
 The bootstrapping process installs various components in K8s that are needed to run the Flux system.

Follow Us

Blog Categories