Skip to content

Flux v2 Basics: Source, Kustomize, and Helm Controllers in the GitOps Toolkit

Interactive Diagram

새 탭 ↗

Summary of Flux v2 Core Concepts and GOTK (GitOps Toolkit) components.

  • Source

    • A Flux source is a configuration resource that can be defined to continuously check the state of a repository.
    • It checks for changes at defined intervals, and when a new version is detected, it internally creates an artifact in the cluster that Flux components can execute.
    • Created as Kubernetes custom resources, the following resource types can be defined:
      • GitRepository, HelmRepository, Bucket (Object Storage).
  • Reconciliation

    • Flux reconciliation means checking whether the state of the artifact created by a Flux source-defined resource matches the currently running state (K8s cluster, infra).
    • If there is a mismatch in the verification process, actions appropriate to the source type can be defined:
      • Kustomization, HelmRelease, Bucket reconciliation.
    • In particular, Kustomization is a custom resource of kustomization.kustomize.toolkit.fluxcd.io, defined for deploying K8s objects via kustomize. Even if there is no kustomization.yml in the repository, all K8s objects are internally deployed through kustomize. https://fluxcd.io/docs/faq/#kustomize-questions
  • Bootstrap

    • Installing FluxCD components on K8s is also executed as a GitOps process, this is called bootstrap.
    • It downloads manifest files from the FluxCD GitHub main repository, stores them in the user’s cluster source repository, and performs configuration changes and redeployment of Flux components through Flux reconciliation.
    • The following tools can be installed to run Flux bootstrap:
      • Flux CLI or Terraform Provider

GitOps Toolkit is the API and Controller Set that constitutes the Flux v2 runtime. APIs are composed of Kubernetes custom resources, and you can directly modify custom resource definitions and deploy them to the cluster.

  • Source Controller
    • GitRepository CRD
    • HelmRepository CRD
    • HelmChart CRD
    • Bucket CRD
  • Kustomize Controller
    • Kustomization CRD
  • Helm Controller
    • HelmRelease CRD
  • Notification Controller
    • Provider CRD
    • Alert CRD
    • Receiver CRD
  • Image reflector & automation controller
    • ImageRepository CRD
    • ImagePolicy CRD
    • ImageUpdateAutomation CRD

When all controllers provided by FluxCD are deployed, 6 deployments from the list above are deployed, and related CRDs are defined in the cluster. Among the controller set, the Source Controller handles artifact creation from source-related custom resources, while the Kustomize Controller and Helm Controller perform the reconciliation role.


Section titled “| Although not precisely verified… the controllers responsible for reconciliation of kustomize/helm (i.e., K8s-related yml definitions in git repositories and helm release automation) are separate, but there is no separate controller for Object Storage reconciliation. For Object Storage, since no separate deployment process is needed after artifact revision regeneration, defining only the Bucket custom resource should handle both source resource management and reconciliation.”

Additionally, the Notification Controller provides supplementary features for 3rd-party integration through defined Alert custom resources.

The Image reflector & automation controller is a single set that manages container image push history and tag application policies, and performs actual deploy automation.

More detailed notes on Source controller, Kustomize controller, Image reflector & automation controller:

Section titled “More detailed notes on Source controller, Kustomize controller, Image reflector & automation controller:”

Source Controller is deployed as a deployment. It detects source custom resources defined by users in the cluster through the API, and when changes are detected, creates Artifacts locally.

Flux Source Controller watching GitRepository, HelmRepository and Bucket CRDs and producing artifacts from Git, Helm and S3 Source: Flux docs, Source Controller, The Flux authors, Apache-2.0

  • Features
    • Source custom resource definition validation check
    • Source authentication (SSH, user/password, API token)
    • Source reliability verification (PGP)
    • Source change detection based on update policy (semver)
    • Source resource fetch on-demand and on schedule
    • Notification on source changes and state changes
      • Notifies notification-controller for 3rd-party integration
    • Packages resources as tar.gz > yaml format and stores locally
      • Creates artifacts as physical files as shown below:
Terminal window
$ ls -tlra /data/gitrepository/flux-system/flux-system/
lrwxrwxrwx 1 controll 1337 91 Jun 8 08:53 latest.tar.gz -> /data/gitrepository/flux-system/flux-system/20ebd9bf70ecc2a061cf2ed0cdff9fd7bc3ab28b.tar.gz
-rw-r--r-- 1 controll 1337 26665 Jun 8 08:53 20ebd9bf70ecc2a061cf2ed0cdff9fd7bc3ab28b.tar.gz

Kustomize Controller compares the artifact created by Source Controller with the current K8s cluster state, and deploys K8s manifests using kustomize.

Flux Kustomize Controller reconciling artifacts into the cluster Source: Flux docs, Kustomize Controller, The Flux authors, Apache-2.0

  • Features
    • Handles K8s cluster reconciliation, can detect changes in multiple source resources
    • Generates manifests for deployment using Kustomize
    • Manifest validation check against the Kubernetes API
    • Impersonation via Service Account (multi-tenancy RBAC)
    • Deployed workload health check
    • Sequential deployment based on defined K8s manifest relationships
    • Prune resources removed from source (Garbage Collection)
    • Cluster state change notification
      • Notifies notification-controller for 3rd-party integration

image-reflector-controller and image-automation-controller are deployed as a set. When a new Container Image is detected, it updates the image tag specified in the Git Repository manifest, enabling Kustomization reconciliation to be performed.

Flux image update automation: the image reflector controller fetches registry tags and the image automation controller patches images in Git Source: Flux docs, Image Automation Controllers, The Flux authors, Apache-2.0

  • Features
    • image-reflector-controller scans ImageRepository and reflects image metadata in Kubernetes resources so that the automation controller can execute
    • image-automation-controller updates, commits, and pushes the yaml of the configured GitRepository based on the scanned latest image metadata