Flux CD for Enterprise GitOps on Kubernetes
Prerequisites
- Working Kubernetes cluster access and kubectl installed
- Git repository access with permissions to create deploy keys or tokens
Steps
Flux CD is a Kubernetes-native GitOps platform that continuously reconciles cluster state from Git and OCI sources. Enterprise teams use it to standardize multi-cluster delivery, improve auditability, and enforce secure, declarative operations at scale.
Overview
Flux CD is an open-source GitOps toolkit for Kubernetes that automates application delivery and cluster configuration by reconciling manifests from Git repositories, Helm charts, and OCI artifacts. Its core purpose is to make the desired state in source control the single source of truth, reducing manual drift and improving repeatability.
Enterprises adopt Flux CD because it is lightweight, CNCF graduated, and designed for Kubernetes-native operations. It supports multi-tenancy, progressive delivery through the broader ecosystem, and strong supply chain patterns using image automation, signed artifacts, and policy controls. For regulated environments, Flux improves traceability because every change is tied to a commit, pull request, and controller event.
Architecture
Flux CD is composed of specialized controllers:
- source-controller fetches Git, Helm, and OCI sources.
- kustomize-controller applies Kustomize manifests to clusters.
- helm-controller manages Helm releases declaratively.
- notification-controller emits events to Slack, Teams, webhooks, and alerting systems.
- image-reflector-controller scans registries for image tags.
- image-automation-controller updates Git based on image policies.
Deployment models
- Single-cluster GitOps: one Flux installation manages one cluster.
- Hub-and-spoke: each cluster runs its own Flux agents, while a central Git platform controls desired state.
- Multi-tenant platform: separate namespaces, service accounts, and Git paths per team.
Data flow
- A developer merges a change into Git.
source-controllerpulls the updated revision.kustomize-controllerorhelm-controllercomputes drift.- Flux applies changes using Kubernetes server-side apply semantics.
- Events and health signals are emitted for observability and audit.
Implementation Guide
1. Install Flux CLI and bootstrap
curl -s https://fluxcd.io/install.sh | sudo bash
flux check --pre
export GITHUB_TOKEN=<token>
export GITHUB_USER=<user>
flux bootstrap github --owner=$GITHUB_USER --repository=platform-gitops --branch=main --path=clusters/prod --personal
2. Create repository structure
mkdir -p clusters/prod apps/payments/base infrastructure/controllers
3. Define a Git source
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: platform-config
namespace: flux-system
spec:
interval: 1m0s
url: https://github.com/acme/platform-gitops
ref:
branch: main
secretRef:
name: flux-system
4. Reconcile cluster manifests
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: prod-cluster
namespace: flux-system
spec:
interval: 5m0s
path: ./clusters/prod
prune: true
wait: true
timeout: 3m0s
sourceRef:
kind: GitRepository
name: platform-config
Apply and verify:
kubectl apply -f gotk-sync.yaml
flux get sources git -A
flux get kustomizations -A
flux reconcile kustomization prod-cluster -n flux-system --with-source
5. Add a Helm-managed application
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: podinfo
namespace: flux-system
spec:
interval: 10m
url: https://stefanprodan.github.io/podinfo
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: podinfo
namespace: apps
spec:
interval: 10m
chart:
spec:
chart: podinfo
version: 6.5.3
sourceRef:
kind: HelmRepository
name: podinfo
namespace: flux-system
values:
replicaCount: 3
Code Examples
Example 1: Bootstrap and health checks
flux bootstrap git --url=ssh://git@github.com/acme/platform-gitops --branch=main --path=clusters/prod --private-key-file=/home/flux/.ssh/id_ed25519
flux get all -A
flux logs --all-namespaces --follow
Example 2: OCI source with signature verification
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: OCIRepository
metadata:
name: app-bundle
namespace: flux-system
spec:
interval: 5m
url: oci://ghcr.io/acme/platform/app-bundle
ref:
tag: 1.4.2
verify:
provider: cosign
Example 3: Alert integration webhook receiver
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: teams
namespace: flux-system
spec:
type: msteams
channel: platform-alerts
secretRef:
name: teams-webhook-url
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: flux-failures
namespace: flux-system
spec:
providerRef:
name: teams
eventSeverity: error
eventSources:
- kind: Kustomization
name: '*'
- kind: HelmRelease
name: '*'
Security Hardening
- Use SOPS with age or cloud KMS to encrypt Kubernetes secrets in Git.
- Restrict controller permissions with namespace-scoped service accounts where possible.
- Prefer SSH deploy keys or GitHub App authentication over long-lived personal tokens.
- Enable branch protection, signed commits, and pull request approvals for GitOps repositories.
- Verify OCI artifacts with Cosign and pin Helm chart versions.
- Separate tenant paths and namespaces, for example
clusters/prod/team-aandclusters/prod/team-b. - Forward Flux events to SIEM platforms for change correlation and incident response.
Comparison
| Feature | Flux CD | Argo CD | Jenkins X |
|---|---|---|---|
| Pricing | Open source, no license fee | Open source, no license fee | Open source; enterprise support varies by vendor |
| Deployment | Kubernetes-native controllers per cluster | Central UI/API plus agents/controllers | Kubernetes-centric platform with CI/CD focus |
| Scalability | Strong for multi-cluster via pull-based reconciliation | Strong, often favored for app-centric fleet views | Better suited to integrated pipeline workflows than pure GitOps |
| Security | Pull model, fine-grained RBAC, SOPS, OCI verification | Strong RBAC, SSO integrations, policy ecosystem | Depends on broader platform design and pipeline controls |
Troubleshooting
1. Git authentication failure
Log sample:
source-controller failed to checkout and determine revision: unable to clone 'https://github.com/acme/platform-gitops': authentication required
Fix: verify secretRef, rotate the deploy key or token, and confirm repository URL and branch permissions.
2. Kustomization path not found
Log sample:
kustomize-controller Reconciliation failed after 125.334ms, next try in 1m0s: kustomization path not found: stat /tmp/flux-workdir/clusters/prod: no such file or directory
Fix: correct spec.path, ensure the directory exists in the tracked branch, then run flux reconcile source git platform-config.
3. Helm release timeout
Log sample:
helm-controller Helm install failed for release apps/podinfo with chart podinfo@6.5.3: context deadline exceeded
Fix: increase spec.timeout, inspect dependent resources with kubectl describe, and confirm image pulls, quotas, and admission policies are not blocking rollout.
Best Practices
Do
- Keep platform, infrastructure, and application manifests in separate paths or repositories.
- Use small, reviewable pull requests with promotion between
dev,stage, andprodbranches or folders. - Set
prune: trueandwait: truefor deterministic reconciliation. - Monitor reconciliation lag, drift events, and failed revisions in Prometheus and centralized logging.
Don't
- Do not give Flux cluster-admin unless the scope truly requires it; bind only the resources each tenant needs.
- Do not store plaintext secrets in Git; use SOPS-encrypted files such as
secret.enc.yaml. - Do not mix manual
kubectl editoperations with GitOps-managed objects; Flux will overwrite drift or leave operators confused. - Do not auto-update images in production without image policies, testing gates, and rollback procedures.
Have a project in mind?
Get an instant AI price estimate for it, or talk directly to our team.
One email a month on what we learn building with AI