Components and Controllers in Flux v2
Flux v2 is a GitOps tool for Kubernetes that automates the deployment and management of applications. A key aspect of Flux v2 is its use of components and controllers to manage the deployment process. In this documentation, we will provide an in-depth look at the various components and controllers in Flux v2.
What is Components and Controllers?
According to the Flux v2 documentation, components are the building blocks of a Flux deployment. They represent the desired state of a Kubernetes application, including its configuration and desired image version. Controllers, on the other hand, are the components that manage the deployment process. They monitor the actual state of the application in the cluster and ensure that it matches the desired state.
Why is Components and Controllers important?
Components and controllers are important because they enable Flux v2 to automate the deployment and management of applications in a GitOps workflow. By defining the desired state of an application as a component, and using controllers to manage the deployment process, Flux v2 can ensure that the actual state of the application in the cluster matches the desired state. This leads to a more reliable and consistent deployment process, as well as easier rollbacks and updates.
Source Controller
The Source Controller is responsible for syncing the desired state of applications from external sources, such as Git repositories, to the Kubernetes cluster. It monitors the external sources for changes, and when a change is detected, it updates the corresponding Kubernetes manifests in the cluster.
Example
Here is an example of using the Source Controller to deploy an application from a Git repository:
apiVersion: sourcer.fluxcd.io/v1beta2
kind: GitRepository
metadata:
name: my-repo
namespace: my-namespace
spec:
url: https://github.com/my-user/my-repo.git
interval: 30s
branch:
name: main
path: ./path/to/manifests
secretRef:
name: my-git-secret
syncPolicy:
automated: true
preImage: true
postImage: true
automaticMerges:
enabled: true
automaticMergesOptions:
strategy: Merge
dependencyUpdates:
enabled: true
dependencyUpdatesOptions:
strategy: Merge
pr:
enabled: false
prPollingInterval: 5m
prTimeout: 1h
prMergeStrategy: Merge
prMergeMessage: "Auto merge from ${{ .Git.Commit.Author.Name }}: ${{ .Git.Commit.Message }}"
prReviewers:
- name: reviewer1
email: [email protected]
- name: reviewer2
email: [email protected]
prLabels:
- name: label1
- name: label2
prBranchProtection:
enabled: false
prBranchProtectionRules: []
prMergeCommitMessage: "Auto merge from ${{ .Git.Commit.Author.Name }}: ${{ .Git.Commit.Message }}"
prMergeCommitMessageTemplate: ""
prMergeCommitMessageTemplateValues: {}
prMergeCommitMessageTemplateFile: ""
prMergeCommitMessageTemplateContent: ""
prMergeCommitMessageTemplateAnnotations: {}
prMergeCommitMessageTemplateAnnotationPrefix: ""
prMergeCommitMessageTemplateAnnotationSuffix: ""
prMergeCommitMessageTemplateAnnotationSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotations: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotations: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotations: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorMatchKinds: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelector: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchLabels: {}
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchExpressions: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchFields: []
prMergeCommitMessageTemplateAnnotationSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorAnnotationsSelectorLabelSelectorMatchKinds