Guest post originally published on Weaveworks’ blog
Developed by Weaveworks in 2016, Flux CD is a GitOps continuous delivery tool used to streamline and automate application deployments. It started as a small, internal project; now it’s a CNCF-graduated project with a large and active community of contributors and users.
In July 2023, the project announced the Generally Available (GA) of Flux CD v2. This milestone indicates that the APIs marked as GA are now stable and reliable for use in production environments. Users can confidently utilize these APIs, knowing that they provide backward compatibility, ensuring existing implementations will work seamlessly as before. While Flux comprises several APIs, not all of them have reached GA status at this time. Flux CD is used by many organizations, including GitLab, Orange, Ring Central, MediaMarktSaturn, and many others.
This page will provide an overview of Flux CD, including what it is, what it does, and how to get started. We will also discuss the Flux CD ecosystem, which includes several other tools and services that can be used to extend the capabilities of Flux CD.
What is Flux CD?
Flux CD is an open-source continuous delivery and GitOps tool designed to simplify and automate the deployment and lifecycle management of applications and infrastructure on Kubernetes. With Flux CD, developers, and operators can declaratively define the desired state of their applications and configurations as code stored in a Git repository.
Flux CD continuously monitors the repository for changes and automatically applies updates to the Kubernetes cluster, ensuring that the actual state matches the desired state. By adopting the GitOps approach, Flux CD enables teams to achieve a reliable and auditable deployment process while promoting collaboration and traceability across different environments. With its flexible architecture and robust feature set, Flux CD has gained popularity as a powerful tool for implementing GitOps workflows and achieving seamless application delivery in Kubernetes environments.
Flux CD Features and Capabilities
Flux CD harnesses the power of GitOps principles to manage Kubernetes resources effectively, ensuring seamless application deployments and robust configuration management. Here are some notable features of Flux CD:
- Automated Deployments: Flux CD automates application deployments by continuously monitoring the Git repository for changes and automatically applying updates to the cluster. This eliminates manual intervention, reduces human error, and ensures consistent deployments.
- GitOps Workflow: Following the GitOps approach, Flux CD allows developers to define the desired state and configuration changes in Git. This promotes version control, collaboration, and auditability, simplifying change management and tracking.
- Progressive Delivery: Leveraging Flagger, Flux CD enables teams to implement progressive delivery strategies such as canary deployments, blue/green releases, and A/B testing. This facilitates safe and controlled application updates in production, minimizing risk.
- Secure by Design: Flux CD is built with security in mind, incorporating pull-based operations, the principle of least privilege, and seamless integration with security tools. These features help maintain a secure deployment pipeline and protect sensitive resources.
- Compatible with all common tools: Flux CD seamlessly integrates with a wide range of popular Kubernetes tools, including Kustomize, Helm, GitHub, GitLab, Harbor, custom webhooks, and policy-driven validations such as OPA and Kyverno. This flexibility allows teams to leverage their preferred tooling and easily incorporate Flux CD into their existing workflows.
Flux CD empowers teams to adopt a robust and scalable CD workflow by automating deployments, ensuring consistent configurations, supporting progressive delivery, prioritizing security, and providing compatibility with various Kubernetes tooling.
How does Flux CD work?
Flux CD is a tool that enables GitOps for managing the configuration of a Kubernetes cluster. In a GitOps pipeline, the desired state of the cluster is stored in a Git repository, and Flux CD ensures that the actual cluster state matches the desired state defined in the repository.
Here’s a simplified explanation of how Flux CD works:
- Flux CD: Flux CD runs as an agent in the Kubernetes cluster and continuously monitors both the Git repository and the cluster for changes.
- Git Repository: The cluster’s desired state, including configurations and resources, is stored in a Git repository. Flux can read Git repositories hosted on platforms like GitHub or GitLab.
- Flux Kustomizations: Flux uses Kustomizations, which are YAML files in a specific directory of the Git repository. These Kustomizations define three critical components:
- Automated Synchronization: When changes are made to the Git repository (e.g., new commits or updates to Kustomizations), Flux detects the changes and automatically synchronizes the cluster to match the new desired state.
- Deployment and Release Automation: Flux CD handles deployment and release automation. It automates the staging and release of containers, services, deployments, network policies, and more on Kubernetes. It is the “glue” connecting the code, services, and running clusters.
Overall, Flux CD streamlines the management of Kubernetes cluster configurations by leveraging version-controlled Git repositories, ensuring consistency, and enabling efficient deployment and release automation.
How to Install Flux CD?
Installing Flux CD is a quick and easy process. First, you need to install the flux CLI. Once you have the CLI installed, you can run a few simple commands to set up a GitOps workflow with a staging and production cluster. The entire process should take just a few minutes.
Install Flux CD CLI:
1- To install the CLI with Homebrew run:
brew install fluxcd/tap/flux
2- Export your GitHub personal access token and username:
3- Check you have everything needed to run Flux by running the following command:
flux check --pre
The output is similar to:
► checking prerequisites
✔ kubernetes 1.27.3 >=1.24.0
✔ prerequisites checks passed
4 – Install Flux in your cluster
Run the bootstrap command:
flux bootstrap github \
The output is similar to:
► connecting to github.com
✔ repository created
✔ repository cloned
✚ generating manifests
✔ components manifests pushed
► installing components in flux-system namespace
deployment "source-controller" successfully rolled out
deployment "kustomize-controller" successfully rolled out
deployment "helm-controller" successfully rolled out
deployment "notification-controller" successfully rolled out
✔ install completed
► configuring deploy key
✔ deploy key configured
► generating sync manifests
✔ sync manifests pushed
► applying sync manifests
◎ waiting for cluster sync
✔ bootstrap finished
For more detailed step-by-step instructions, visit Flux CD’s Getting Started page.
FluxCD: GitOps Toolkit Components
Flux CD is constructed with the GitOps Toolkit components: a set of composable APIs and specialized tools that are used to build a continuous delivery platform on top of Kubernetes.
The toolkit can be used to extend Flux CD’s functionality and to build continuous delivery systems.
The GitOps Toolkit Components include:
- Source controller: It provides a common interface for artifact acquisition. The Source Controller enables seamless integration of various Git repositories with your Kubernetes cluster. It constantly monitors the repositories for changes, such as new commits or updates to manifests, and automatically synchronizes those changes to your cluster.
- Kustomize Controller: Leveraging Kustomize, a popular configuration management tool, the Kustomize Controller enables cluster administrators to customize and tailor Kubernetes manifests for different environments without modifying the original source files. This allows for streamlined and automated deployments across multiple environments, simplifying the process of managing complex configurations.
- Helm Controller: this controller is used to declaratively manage Helm chart releases with Kubernetes manifest. It enables seamless installation, upgrade, and deletion of Helm releases directly from Git repositories.
- Notification Controller: This controller facilitates the integration of notifications, allowing teams to receive real-time alerts and updates about the state of their deployments and configurations. Whether it’s through popular communication platforms like Slack or email, the Notification Controller keeps teams informed of any changes, errors, or successful deployments, enabling quick responses to potential issues and ensuring smooth operations.
- Image Reflector and Automation Controller: these controllers work together to keep a Git repository up-to-date with the latest container images. The image-reflector-controller scans image repositories and creates Kubernetes resources that reflect the image metadata. The image automation controller then updates YAML files in the Git repository based on the latest images scanned.
What you need to build a GitOps Pipeline with Flux CD
Flux CD enables GitOps deployments and provides a way to manage deployments on Kubernetes. It automates the staging and release of containers to Kubernetes by. How does it fit into the GitOps pipeline and what exactly do you need to build a GitOps pipeline? Let’s find out.
A declarative system for managing the containers in which your app will run. An example of this is Kubernetes. But when we say ‘example,’ we mean it’s really the only choice. Kubernetes is now ubiquitous, and its ecosystem, as we’ll see, is enormous
Code Repository (Git Management)
Central to any software development lifecycle is using an online Git hosting platform, to simplify team collaboration around these cloud-hosted repositories. A Git repository manages changes, stores version history, and is built to deal with complex repository branching. Some of the most popular Git tools include GitHub and GitLab but there are many more out there.
Container Image Registry
A container registry serves as a repository for storing the comprehensive information, files, and components of an application in the form of container images. These container images function as templates to facilitate rapid application development and scalability. An example here would be Docker Hub, Amazon ECR, and Quay.io.
Flux CD: A Reconciliation (GitOps) Agent
The reconciliation agent (Flux CD) is a software that ensures that the application running on Kubernetes matches the description in your Git repositories. It acts as a bridge between Git and Kubernetes, watching what is happening in production and continuously comparing it to the description of what should be happening in Git.
The reconciliation agent can trigger various reparatory sequences if there are discrepancies. These sequences may include automated fixing or alerts to your platform team. The goal is to restore equilibrium between the application in production and the description in Git.
This is arguably the most important part of a GitOps pipeline. Flux CD is one of the leading GitOps agents today. It works with all Git providers and various container registries and can be seamlessly integrated with other automation tools.
As your operation expands, the number of developers contributing to your codebase increases. They frequently submit updates or commits, which can lead to a large volume of changes. Managing this continuous integration of code updates, known as CI, becomes crucial to avoid potential errors. Automating certain aspects of the process is essential, and this is where a build server plays a pivotal role. A build server is a software that automates the building of each new update, pushing it forward in the pipeline towards production. Examples of popular build servers include Jenkins X and CircleCI.
Flux CD Ecosystem
Initially developed by Weaveworks, Flux CD is now maintained by the community as part of the Flux CD project. With its growing popularity and adoption, more companies and more projects contributed add-on capabilities. Products and solutions were built using Flux CD, such as Azure, D2iQ Kommander, Giant Swarm, and our Weaveworks’ Weave GitOps Assured and Weave GitOps Enterprise.
There are many other tools that came to light to extend Flux CD capabilities, including:
Visual Studio Code Extension
The Visual Studio Code Extension is built on Flux CD and can be used to visualize, configure, and debut Flux objects (sources and workloads) needed for GitOps workflows. This extension dramatically simplifies application deployment for developers, enabling them to deploy code directly from VS Code without needing to be an expert on Kubernetes. Check the Visual Studio Marketplace for the complete list of features and installation instructions.
- GitOps Without Leaving your IDE
- GitOps Deployments from VS Code with little to no Kubernetes Knowledge
The Terraform Controller is a specialized controller integrated with Flux
designed to apply GitOps principles to Terraform resources. Leveraging the combined capabilities of Flux and Terraform, TF-controller allows you to adopt GitOps practices for both infrastructure and application resources within the Kubernetes and Terraform ecosystem. Check out the documentation and use cases.
Flamingo is a Flux subsystem for Argo CD, where users can get the best of both worlds for implementing GitOps on Kubernetes clusters. This powerful tool couples Argo CD’s user-friendly interface Argo CD, with the automation capabilities of Flux CD integrated into it, streamlining deployment management.
Read about it in our blog “Flamingo: Expand Argo CD with Flux“.
Weave GitOps is a full-stack GitOps platform that enables developers to easily deploy applications using GitOps into any Kubernetes cluster. Powered by Flux CD, Weave GitOps is a free and open-source GUI for Flux under the weave-gitops project. Weave GitOps UI provides the Ops team with key information to help them discover and resolve issues easily.
AKS & Azure Arc
Flux CD is used to enable GitOps in Azure Kubernetes Service (AKS) and Azure Arc-enabled Kubernetes (Arc K8s). It’s available as addon that is installed and managed by Azure. Through the Flux CD integration, users have a secure and reliable toolkit for managing and deploying declarative configuration to Kubernetes clusters while adhering to the GitOps principles.
- The New GitOps Extension on AKS and Azure Arc Enables Trusted Delivery and Control
- Watch – GitOps in Microsoft Azure with Flux by Chris Sanders & Jonathan Innis
- Tutorial: Implement CI/CD with GitOps (Flux v2)
- Tutorial: Deploy applications using GitOps with Flux v2
EKS Anywhere integrates with Flux CD to support GitOps workflows for cluster management. Users can set up Flux CD (optionally) and commit the cluster configuration to a Git repository. Flux CD will then watch the committed configuration file in Git and keep the actual cluster state in sync with the desired state described in the configuration file.
- EKS Anywhere – Manage Cluster with GitOps
- Blue/Green Kubernetes upgrades for Amazon EKS Anywhere using Flux
- Watch – GitOps with Amazon EKS Anywhere + Flux – Dan Budris
Scaling Flux CD with Weave GitOps
Weave GitOps is a state-of-the-art GitOps solution powered by Flux and Flagger. It enables developers to easily deploy applications using GitOps into any Kubernetes cluster and frees up operators from manual tasks. With Weave GitOps, DevOps teams can build and maintain GitOps pipeline that introduce continuous delivery, stage promotions, and progressive delivery.
Weaveworks offers two tiers of GitOps solutions:
- Weave GitOps Assured: if you’re using Flux CD in production, this solution is best for you. It combines open-source software for continuous and progressive delivery with enterprise-level support (CVE, hot fixes) from cloud-native experts.
- Weave GitOps Enterprise: For those looking to scale their GitOps operations, Weave GitOps is the perfect solution. It offers an easier onboarding experience, allowing users to install and visualize not just Flux CD, but also Helm Charts and application deployments, via its web-based user interface. It gives teams with limited Kubernetes expertise the tools they need to deploy applications easily and securely.
Contact Us for a Demo to learn more.