Source Controller and Git Repositories
You'll learn how Flux's Source Controller continuously monitors Git repositories and syncs Kubernetes manifests using GitRepository resources.
What is the Source Controller?
The Source Controller is one of Flux's core components that acts like a persistent librarian for your infrastructure code. Instead of manually pulling changes from Git, it automatically watches your repositories and downloads updates whenever they occur. Think of it as a vigilant assistant that checks your Git repo periodically, saying "Has anything changed? Let me grab that for you."
The GitRepository Resource
A GitRepository is a Flux custom resource that tells the Source Controller which Git repository to monitor, which branch or tag to track, and how often to check for changes. When you define a GitRepository, you're essentially giving Flux a bookmark with instructions: "Check this URL every X minutes and download the latest manifests."
Reconciliation Intervals
The reconciliation interval controls how frequently Flux checks your Git repository. Set it using the interval field (e.g., 1m, 5m, 10m). A shorter interval means faster detection of changes but more API calls to your Git provider. A longer interval reduces load but delays updates.
The Source Controller doesn't just check once—it continuously reconciles, ensuring your cluster's desired state always reflects what's in Git.
How It Works
When you create a GitRepository resource, the Source Controller clones the specified branch, stores it locally as an artifact (usually a tarball), and makes it available to other Flux components like Kustomize Controller or Helm Controller. Every reconciliation interval, it checks for new commits and re-fetches if needed.
Key Takeaway: The Source Controller's GitRepository resource automates Git synchronization by periodically polling repositories at defined intervals, ensuring your Kubernetes manifests stay current without manual intervention.