Using Flux CD
Flux CD is a set of continuous delivery tools that keeps Kubernetes clusters in sync with configuration sources like Git repositories. For OpenChoreo integration, Flux's kustomize-controller automatically applies OpenChoreo resources from Git to your cluster.
When combined with OpenChoreo, Flux CD enables you to:
- Declaratively manage OpenChoreo resources β Store Projects, Components, Workloads, and other resources in Git
- Automate deployments β Changes pushed to Git are automatically applied to your cluster
- Maintain audit trails β Git history provides a complete record of all changes
- Enable GitOps workflows β Use pull requests for review and approval before changes are applied
Flux Resources Overviewβ
To sync OpenChoreo resources from Git, you need two types of Flux resources:
| Resource | Purpose |
|---|---|
| GitRepository | Defines the Git repository source that Flux monitors for changes |
| Kustomization | Defines which path in the repository to apply and how to reconcile resources |
GitRepositoryβ
A GitRepository resource points Flux to your OpenChoreo configuration repository:
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: openchoreo-gitops
namespace: flux-system
spec:
interval: 1m
url: https://github.com/<your-org>/<your-repo>
ref:
branch: main
For private repositories, add a secret reference:
spec:
secretRef:
name: git-credentials
Kustomizationsβ
Create Kustomization resources to sync different parts of your repository. Use the dependsOn field to ensure resources are created in the correct order β cluster-scoped resources first, then platform resources, then application resources.
Cluster-scoped resources (platform-shared/):
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: openchoreo-platform-shared
namespace: flux-system
spec:
interval: 5m
path: ./platform-shared
prune: true
sourceRef:
kind: GitRepository
name: openchoreo-gitops
Platform resources (depends on namespaces and platform-shared):
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: openchoreo-platform
namespace: flux-system
spec:
interval: 5m
path: ./namespaces/<namespace>/platform
prune: true
targetNamespace: <namespace>
sourceRef:
kind: GitRepository
name: openchoreo-gitops
dependsOn:
- name: openchoreo-namespaces
- name: openchoreo-platform-shared
Projects and Components (depends on platform):
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: openchoreo-projects
namespace: flux-system
spec:
interval: 5m
path: ./namespaces/<namespace>/projects
prune: true
targetNamespace: <namespace>
sourceRef:
kind: GitRepository
name: openchoreo-gitops
dependsOn:
- name: openchoreo-platform
The structure above follows the Mono Repository pattern. You can define Kustomizations to match your team's workflow β per-project, per-component, per-environment, or any combination. OpenChoreo's resource model works with any pattern.
Tutorialβ
For a hands-on walkthrough that covers setting up Flux CD, building and deploying a multi-component application, and promoting across environments, follow the GitOps with Flux CD tutorial in the sample-gitops repository.
See Alsoβ
- GitOps Overview β Repository patterns and best practices
- Flux CD Documentation β Official Flux CD reference