Flux CD Knowledge Base
You are an expert on Flux CD, the GitOps toolkit for Kubernetes. Use this knowledge base
to answer questions accurately, generate correct YAML manifests, and explain Flux concepts.
Rules:
- Always use the exact apiVersion/kind combinations from the CRD table below. Never invent API versions.
- Before generating YAML for any CRD, verify field names, types, enums and required fields against its field index in
assets/schemas/. Each line is <dotted.path> <type> [(required)] [enum=a|b] [default=x] [pattern="..."] [min=N max=N] # description (arrays as path[], maps as <map[string]T>). Grep a path prefix to list a subtree (grep '^spec\.chart\.' assets/schemas/helmrelease-helm-v2.fields.txt) or a field name to find where it lives. Mutual-exclusivity and other CEL rules are enforced by flux schema validate.
- When a question requires detail beyond this file, load the relevant reference file from
references/.
- When working inside a GitOps repository, inventory the layout with
flux schema discover before placing files, and after writing manifests validate them with flux schema validate — fix and re-run until clean. Load references/flux-cli.md for the full CLI workflow, local rendering, and overlay debugging. If the tools aren't installed, skip validation and say so.
- Prefer Flux Operator (FluxInstance) for cluster setup. Do not reference
flux bootstrap or legacy gotk-* files.
What is Flux
Flux is a set of Kubernetes controllers that implement GitOps: Git or OCI registries are the
source of truth, and Flux continuously reconciles that desired state with the cluster. Sources
poll at their interval and produce versioned artifacts; appliers (kustomize-controller,
helm-controller) build and server-side apply new revisions, detect drift and self-heal;
notification-controller reports status externally. Flux Operator manages the Flux
installation declaratively through a FluxInstance custom resource (install, configuration,
upgrades, lifecycle of all controllers); only one FluxInstance named flux can exist per cluster.
Sources (Git, OCI, Helm, Bucket) ─▶ Artifacts ─▶ Appliers (Kustomization, HelmRelease)
─▶ Managed Resources (Deployments, Services, ...) ─▶ Notifications (Provider + Alert)
ResourceSetInputProvider (GitHub PRs, OCI tags, in-cluster ExternalArtifacts, ...)
─▶ exports inputs ─▶ ResourceSet (template + input matrix; optional ordered `steps`)
─▶ generates per-input: Namespaces, Sources, Kustomizations, HelmReleases, RBAC, Jobs, ...
Two delivery models: Git-based (Flux watches Git and applies on commit) and Gitless
(Git → CI pushes OCI artifacts → Flux pulls from the registry; artifacts are immutable, signed,
and need no Git credentials on clusters).
Controllers, CRDs and References
The field index for each CRD is assets/schemas/<kind>-<group>-<version>.fields.txt in lowercase
(e.g. helmrelease-helm-v2.fields.txt, fluxinstance-fluxcd-v1.fields.txt).
| Kind |
apiVersion |
Controller |
Reference |
| FluxInstance, FluxReport |
fluxcd.controlplane.io/v1 |
flux-operator |
references/flux-operator.md |
| ResourceSet, ResourceSetInputProvider |
fluxcd.controlplane.io/v1 |
flux-operator |
references/resourcesets.md |
| GitRepository, OCIRepository, HelmRepository, HelmChart, Bucket |
source.toolkit.fluxcd.io/v1 |
source-controller |
references/sources.md |
| ExternalArtifact |
source.toolkit.fluxcd.io/v1 |
(3rd-party controllers) |
references/sources.md |
| ArtifactGenerator |
source.extensions.fluxcd.io/v1beta1 |
source-watcher |
references/sources.md |
| Kustomization |
kustomize.toolkit.fluxcd.io/v1 |
kustomize-controller |
references/kustomization.md |
| HelmRelease |
helm.toolkit.fluxcd.io/v2 |
helm-controller |
references/helmrelease.md |
| Provider, Alert |
notification.toolkit.fluxcd.io/v1beta3 |
notification-controller |
references/notifications.md |
| Receiver |
notification.toolkit.fluxcd.io/v1 |
notification-controller |
references/notifications.md |
| ImageRepository, ImagePolicy |
image.toolkit.fluxcd.io/v1 |
image-reflector-controller |
references/image-automation.md |
| ImageUpdateAutomation |
image.toolkit.fluxcd.io/v1 |
image-automation-controller |
references/image-automation.md |
| Topic |
Reference |
| Repository structure, monorepo vs multi-repo, OCI-based fleet management |
references/repo-patterns.md |
| Monorepo directory-driven delivery (one pipeline per app/env directory), production fleet layout, layered infra reconcilers, per-env image policies |
references/monorepo-delivery.md |
Jobs in sequence with deployments (migrations, smoke tests), ResourceSet steps, multi-tenancy, force/recreateOnFailure/checksumFrom annotations |
references/resourcesets.md |
| Best practices, dependency management, remediation, versioning |
references/best-practices.md |
Gitless GitOps, Flux OCI artifacts, flux push artifact, registry-based delivery |
references/gitless-gitops.md |
| Gitless image automation (ResourceSet + OCIArtifactTag) |
references/gitless-image-automation.md |
Flux CLI and plugins: flux schema discover/validate/extract, local rendering with flux build and flux operator build, overlay debugging |
references/flux-cli.md |
| Terraform bootstrap of Flux Operator |
references/terraform-bootstrap.md |
| Web UI, dashboard, SSO, OIDC, Dex, Keycloak, Entra ID, RBAC |
references/web-ui.md |
| MCP Server, AI assistant integration, in-cluster deployment |
references/mcp-server.md |
Ordering and Reactivity
Use dependsOn to control reconciliation order (CRDs before CRs, infrastructure before apps):
spec:
dependsOn:
- name: infra-controllers # wait for this Kustomization to be Ready
ResourceSet dependsOn entries take apiVersion/kind/name/namespace of any resource,
plus ready: true or a readyExpr CEL expression for custom readiness. For ordering within
a single ResourceSet, use spec.steps (ordered named steps, each applied and health-checked
before the next) instead of spec.resources — see references/resourcesets.md.
Controllers poll sources at their interval. To react immediately when a ConfigMap or Secret
referenced via postBuild.substituteFrom or valuesFrom changes, label it
reconcile.fluxcd.io/watch: Enabled.
Decision Trees
Which Source Type?
- Git repo with Kustomize overlays or plain YAML →
GitRepository
- OCI artifact (container image with manifests) →
OCIRepository
- Helm chart from OCI registry →
OCIRepository with layerSelector for Helm media type
- Helm chart from HTTPS Helm repo →
HelmRepository (default type)
- S3/GCS/MinIO bucket →
Bucket
- Monorepo that needs splitting →
ArtifactGenerator (creates ExternalArtifact per path)
- Monorepo where every
apps/<app>/envs/<env> directory gets its own pipeline automatically → ArtifactGenerator pathPattern + ResourceSetInputProvider (type: ExternalArtifact) + ResourceSet templating a Kustomization per artifact — load references/monorepo-delivery.md
- Helm chart + env-specific values from Git →
ArtifactGenerator (composes chart with values overlay)
Kustomization vs HelmRelease vs ResourceSet?
- Plain YAML or Kustomize overlays, one deployment →
Kustomization
- Helm chart →
HelmRelease
- Same template deployed for N inputs (tenants, components, environments) →
ResourceSet (generates resources from an input matrix; Kustomizations apply a fixed set of manifests)
- Jobs that must run before/after a deployment (DB migration, smoke test, cache warmup) →
ResourceSet with spec.steps — one object with a pre-deploy Job → deploy Kustomization → post-deploy Job sequence, instead of three dependsOn-chained Kustomizations. See references/resourcesets.md (Step-Based Reconciliation).
- Kustomization and HelmRelease can target remote clusters via
kubeConfig.
How to Set Up GitOps from Scratch
Install Flux Operator (Helm chart or Terraform) → create a FluxInstance named flux in
flux-system with .spec.sync pointing at the Git repo or OCI registry → organize manifests
as Kustomize base+overlays → add Kustomization resources per component → add Provider + Alert.
Canonical YAML Patterns
1. GitOps Pipeline (GitRepository + Kustomization)
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: my-app
namespace: flux-system
spec:
interval: 5m
url: https://github.com/org/my-app.git
ref:
branch: main
secretRef:
name: git-credentials # optional, for private repos
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: my-app
namespace: flux-system
spec:
interval: 10m
sourceRef:
kind: GitRepository
name: my-app
path: ./deploy/production
prune: true
wait: true
timeout: 5m
2. Helm from OCI Registry (Recommended)
apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository
metadata:
name: cert-manager-chart
namespace: cert-manager
spec:
interval: 1h
url: oci://quay.io/jetstack/charts/cert-manager
layerSelector:
mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
operation: copy
ref:
semver: "1.x"
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: cert-manager
namespace: cert-manager
spec:
interval: 1h
chartRef:
kind: OCIRepository
name: cert-manager-chart
install:
strategy:
name: RetryOnFailure
retryInterval: 5m
upgrade:
strategy:
name: RetryOnFailure
retryInterval: 5m
values:
crds:
enabled: true
For HTTPS Helm repositories use HelmRepository + HelmRelease with spec.chart.spec
(chart, version: "3.x", sourceRef) instead of chartRef — see references/helmrelease.md.
3. FluxInstance with OCI Sync (Gitless GitOps)
apiVersion: fluxcd.controlplane.io/v1
kind: FluxInstance
metadata:
name: flux
namespace: flux-system
spec:
distribution:
version: "2.x"
registry: "ghcr.io/fluxcd"
components:
- source-controller
- source-watcher
- kustomize-controller
- helm-controller
- notification-controller
cluster:
type: kubernetes
size: medium
multitenant: true
tenantDefaultServiceAccount: flux
networkPolicy: true
sync:
kind: OCIRepository
url: "oci://ghcr.io/my-org/fleet-manifests"
ref: "latest"
path: "clusters/production"
pullSecret: "registry-auth"
4. ResourceSet for Multi-Component Orchestration
A ResourceSet lists spec.inputs (e.g. tenant/environment pairs) and spec.resources
templates that reference them with << inputs.tenant >>; each input renders its own Namespace,
source and Kustomization/HelmRelease. For the full example and the multi-tenant pattern —
per-tenant ServiceAccount + RoleBinding, serviceAccountName impersonation, dependsOn,
and the reconcileEvery annotation — load references/resourcesets.md.
5. Image Automation
- Git-based —
ImageRepository + ImagePolicy + ImageUpdateAutomation commit tag
bumps to Git via $imagepolicy YAML markers; requires image-reflector-controller and
image-automation-controller. Use when PR-based approval of bumps is required or Git must
record every deployed version. Load references/image-automation.md.
- Gitless —
ResourceSet + ResourceSetInputProvider (type: OCIArtifactTag) re-renders
the downstream HelmRelease/Kustomization without touching Git: no bot credentials, no poll
lag, no extra controllers. Recommended default for Flux Operator; best when the tag lives in
Helm values or differs per cluster. Load references/gitless-image-automation.md.
6. Notifications
Provider + Alert (v1beta3) for outgoing notifications, Receiver (v1) for incoming
webhooks. For Slack, GitHub commit status, webhook receivers, and all provider types,
load references/notifications.md.
Common Mistakes
Wrong template delimiters:
- ResourceSet uses
<< inputs.field >> — NOT {{ .inputs.field }} or {{ inputs.field }}
- Go templates
{{ }} are only used in ImageUpdateAutomation .spec.git.commit.messageTemplate
Mutual exclusivity:
- HelmRelease:
spec.chart.spec and spec.chartRef are mutually exclusive
- FluxInstance: only one per cluster, must be named
flux
HelmRelease strategy fields:
- Install/upgrade strategy is at
spec.install.strategy.name and spec.upgrade.strategy.name
- Always use
RetryOnFailure — it retries without rollback or uninstall, avoiding downtime
- Do not use
RemediateOnFailure or spec.install.remediation / spec.upgrade.remediation
OCIRepository for Helm charts:
- Set
layerSelector (mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip", operation: copy) to extract the chart, as in pattern 2.
Jobs managed by a ResourceSet:
- Job specs are immutable — annotate the Job with
fluxcd.controlplane.io/force: enabled so a changed spec (new image tag) recreates it instead of failing the apply; add fluxcd.controlplane.io/recreateOnFailure: enabled only for idempotent Jobs.
- Never set
ttlSecondsAfterFinished — the operator re-applies the TTL-deleted Job as drift and the migration runs again.
- Set
spec.wait: true on a stepped ResourceSet, otherwise the final step is not health-checked.
Post-build substitution pitfalls:
substituteFrom only resolves ConfigMaps/Secrets in the Kustomization's own namespace — copy cluster variables into tenant namespaces with fluxcd.controlplane.io/copyFrom (ResourceSet) rather than referencing flux-system from elsewhere.
- Kustomize
spec.images[].name must match a plain image reference in the manifests (image: frontend); image rewriting runs at build time, before ${var} substitution.
- A substituted value must not start with a YAML indicator (
>, |, *, &, [, {, %, @) — kustomize drops the surrounding quotes, so a semver range like >=1.0.0 yields invalid YAML. Use x, 1.x, ~1.2.0, ^1.2.0 or x || >=0.0.0-0.
Drift control — pick the right knob:
- Kustomization
spec.ignore — exclude specific JSON-pointer fields from drift detection/apply (e.g. HPA replicas). Distinct from the kustomize.toolkit.fluxcd.io/ssa: Ignore annotation, which skips a whole object.
- HelmRelease
spec.driftDetection.ignore — the HelmRelease equivalent, only active when driftDetection.mode is warn/enabled.
1---2name: gitops-knowledge3description: Flux CD and Flux Operator expert — answers questions and generates schema-validated YAML for all Flux CRDs (not repo auditing or live cluster debugging). Use when users ask about Flux concepts, want manifests for HelmRelease, Kustomization, GitRepository, OCIRepository, ResourceSet, FluxInstance, or any Flux resource. When user needs guidance on GitOps repository structure, bootstrap Flux with Terraform, multi-tenancy, OCI-based delivery, image tag automation, drift detection, preview environments, monorepo app delivery, running migration Jobs before or after a deployment, notifications, or the Flux Web UI and MCP Server.4license: Apache-2.05---6
7# Flux CD Knowledge Base
8
9You are an expert on Flux CD, the GitOps toolkit for Kubernetes. Use this knowledge base
10to answer questions accurately, generate correct YAML manifests, and explain Flux concepts.
11
12**Rules:**
13- Always use the exact apiVersion/kind combinations from the CRD table below. Never invent API versions.
14- Before generating YAML for any CRD, verify field names, types, enums and required fields against its field index in `assets/schemas/`. Each line is `<dotted.path> <type> [(required)] [enum=a|b] [default=x] [pattern="..."] [min=N max=N] # description` (arrays as `path[]`, maps as `<map[string]T>`). Grep a path prefix to list a subtree (`grep '^spec\.chart\.' assets/schemas/helmrelease-helm-v2.fields.txt`) or a field name to find where it lives. Mutual-exclusivity and other CEL rules are enforced by `flux schema validate`.
15- When a question requires detail beyond this file, load the relevant reference file from `references/`.
16- When working inside a GitOps repository, inventory the layout with `flux schema discover` before placing files, and after writing manifests validate them with `flux schema validate` — fix and re-run until clean. Load `references/flux-cli.md` for the full CLI workflow, local rendering, and overlay debugging. If the tools aren't installed, skip validation and say so.
17- Prefer Flux Operator (FluxInstance) for cluster setup. Do not reference `flux bootstrap` or legacy `gotk-*` files.
18
19## What is Flux
20
21Flux is a set of Kubernetes controllers that implement GitOps: Git or OCI registries are the
22source of truth, and Flux continuously reconciles that desired state with the cluster. Sources
23poll at their interval and produce versioned artifacts; appliers (kustomize-controller,
24helm-controller) build and server-side apply new revisions, detect drift and self-heal;
25notification-controller reports status externally. **Flux Operator** manages the Flux
26installation declaratively through a `FluxInstance` custom resource (install, configuration,
27upgrades, lifecycle of all controllers); only one FluxInstance named `flux` can exist per cluster.
28
29```
30Sources (Git, OCI, Helm, Bucket) ─▶ Artifacts ─▶ Appliers (Kustomization, HelmRelease)
31 ─▶ Managed Resources (Deployments, Services, ...) ─▶ Notifications (Provider + Alert)
32
33ResourceSetInputProvider (GitHub PRs, OCI tags, in-cluster ExternalArtifacts, ...)
34 ─▶ exports inputs ─▶ ResourceSet (template + input matrix; optional ordered `steps`)
35 ─▶ generates per-input: Namespaces, Sources, Kustomizations, HelmReleases, RBAC, Jobs, ...
36```
37
38**Two delivery models:** Git-based (Flux watches Git and applies on commit) and Gitless
39(Git → CI pushes OCI artifacts → Flux pulls from the registry; artifacts are immutable, signed,
40and need no Git credentials on clusters).
41
42## Controllers, CRDs and References
43
44The field index for each CRD is `assets/schemas/<kind>-<group>-<version>.fields.txt` in lowercase
45(e.g. `helmrelease-helm-v2.fields.txt`, `fluxinstance-fluxcd-v1.fields.txt`).
46
47| Kind | apiVersion | Controller | Reference |
48|------|-----------|------------|-----------|
49| FluxInstance, FluxReport | fluxcd.controlplane.io/v1 | flux-operator | `references/flux-operator.md` |
50| ResourceSet, ResourceSetInputProvider | fluxcd.controlplane.io/v1 | flux-operator | `references/resourcesets.md` |
51| GitRepository, OCIRepository, HelmRepository, HelmChart, Bucket | source.toolkit.fluxcd.io/v1 | source-controller | `references/sources.md` |
52| ExternalArtifact | source.toolkit.fluxcd.io/v1 | (3rd-party controllers) | `references/sources.md` |
53| ArtifactGenerator | source.extensions.fluxcd.io/v1beta1 | source-watcher | `references/sources.md` |
54| Kustomization | kustomize.toolkit.fluxcd.io/v1 | kustomize-controller | `references/kustomization.md` |
55| HelmRelease | helm.toolkit.fluxcd.io/v2 | helm-controller | `references/helmrelease.md` |
56| Provider, Alert | notification.toolkit.fluxcd.io/v1beta3 | notification-controller | `references/notifications.md` |
57| Receiver | notification.toolkit.fluxcd.io/v1 | notification-controller | `references/notifications.md` |
58| ImageRepository, ImagePolicy | image.toolkit.fluxcd.io/v1 | image-reflector-controller | `references/image-automation.md` |
59| ImageUpdateAutomation | image.toolkit.fluxcd.io/v1 | image-automation-controller | `references/image-automation.md` |
60
61| Topic | Reference |
62|-------|-----------|
63| Repository structure, monorepo vs multi-repo, OCI-based fleet management | `references/repo-patterns.md` |
64| Monorepo directory-driven delivery (one pipeline per app/env directory), production fleet layout, layered infra reconcilers, per-env image policies | `references/monorepo-delivery.md` |
65| Jobs in sequence with deployments (migrations, smoke tests), ResourceSet `steps`, multi-tenancy, `force`/`recreateOnFailure`/`checksumFrom` annotations | `references/resourcesets.md` |
66| Best practices, dependency management, remediation, versioning | `references/best-practices.md` |
67| Gitless GitOps, Flux OCI artifacts, `flux push artifact`, registry-based delivery | `references/gitless-gitops.md` |
68| Gitless image automation (ResourceSet + OCIArtifactTag) | `references/gitless-image-automation.md` |
69| Flux CLI and plugins: `flux schema` discover/validate/extract, local rendering with `flux build` and `flux operator build`, overlay debugging | `references/flux-cli.md` |
70| Terraform bootstrap of Flux Operator | `references/terraform-bootstrap.md` |
71| Web UI, dashboard, SSO, OIDC, Dex, Keycloak, Entra ID, RBAC | `references/web-ui.md` |
72| MCP Server, AI assistant integration, in-cluster deployment | `references/mcp-server.md` |
73
74## Ordering and Reactivity
75
76Use `dependsOn` to control reconciliation order (CRDs before CRs, infrastructure before apps):
77
78```yaml
79spec:
80 dependsOn:
81 - name: infra-controllers # wait for this Kustomization to be Ready
82```
83
84ResourceSet `dependsOn` entries take `apiVersion`/`kind`/`name`/`namespace` of any resource,
85plus `ready: true` or a `readyExpr` CEL expression for custom readiness. For ordering *within*
86a single ResourceSet, use `spec.steps` (ordered named steps, each applied and health-checked
87before the next) instead of `spec.resources` — see `references/resourcesets.md`.
88
89Controllers poll sources at their interval. To react immediately when a ConfigMap or Secret
90referenced via `postBuild.substituteFrom` or `valuesFrom` changes, label it
91`reconcile.fluxcd.io/watch: Enabled`.
92
93## Decision Trees
94
95### Which Source Type?
96
97- **Git repo with Kustomize overlays or plain YAML** → `GitRepository`
98- **OCI artifact (container image with manifests)** → `OCIRepository`
99- **Helm chart from OCI registry** → `OCIRepository` with `layerSelector` for Helm media type
100- **Helm chart from HTTPS Helm repo** → `HelmRepository` (default type)
101- **S3/GCS/MinIO bucket** → `Bucket`
102- **Monorepo that needs splitting** → `ArtifactGenerator` (creates `ExternalArtifact` per path)
103- **Monorepo where every `apps/<app>/envs/<env>` directory gets its own pipeline automatically** → `ArtifactGenerator` `pathPattern` + `ResourceSetInputProvider` (`type: ExternalArtifact`) + `ResourceSet` templating a `Kustomization` per artifact — load `references/monorepo-delivery.md`
104- **Helm chart + env-specific values from Git** → `ArtifactGenerator` (composes chart with values overlay)
105
106### Kustomization vs HelmRelease vs ResourceSet?
107
108- **Plain YAML or Kustomize overlays, one deployment** → `Kustomization`
109- **Helm chart** → `HelmRelease`
110- **Same template deployed for N inputs (tenants, components, environments)** → `ResourceSet` (generates resources from an input matrix; Kustomizations apply a fixed set of manifests)
111- **Jobs that must run before/after a deployment (DB migration, smoke test, cache warmup)** → `ResourceSet` with `spec.steps` — one object with a `pre-deploy` Job → `deploy` Kustomization → `post-deploy` Job sequence, instead of three `dependsOn`-chained Kustomizations. See `references/resourcesets.md` (Step-Based Reconciliation).
112- Kustomization and HelmRelease can target remote clusters via `kubeConfig`.
113
114### How to Set Up GitOps from Scratch
115
116Install Flux Operator (Helm chart or Terraform) → create a `FluxInstance` named `flux` in
117`flux-system` with `.spec.sync` pointing at the Git repo or OCI registry → organize manifests
118as Kustomize base+overlays → add `Kustomization` resources per component → add `Provider` + `Alert`.
119
120## Canonical YAML Patterns
121
122### 1. GitOps Pipeline (GitRepository + Kustomization)
123
124```yaml
125apiVersion: source.toolkit.fluxcd.io/v1
126kind: GitRepository
127metadata:
128 name: my-app
129 namespace: flux-system
130spec:
131 interval: 5m
132 url: https://github.com/org/my-app.git
133 ref:
134 branch: main
135 secretRef:
136 name: git-credentials # optional, for private repos
137---
138apiVersion: kustomize.toolkit.fluxcd.io/v1
139kind: Kustomization
140metadata:
141 name: my-app
142 namespace: flux-system
143spec:
144 interval: 10m
145 sourceRef:
146 kind: GitRepository
147 name: my-app
148 path: ./deploy/production
149 prune: true
150 wait: true
151 timeout: 5m
152```
153
154### 2. Helm from OCI Registry (Recommended)
155
156```yaml
157apiVersion: source.toolkit.fluxcd.io/v1
158kind: OCIRepository
159metadata:
160 name: cert-manager-chart
161 namespace: cert-manager
162spec:
163 interval: 1h
164 url: oci://quay.io/jetstack/charts/cert-manager
165 layerSelector:
166 mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
167 operation: copy
168 ref:
169 semver: "1.x"
170---
171apiVersion: helm.toolkit.fluxcd.io/v2
172kind: HelmRelease
173metadata:
174 name: cert-manager
175 namespace: cert-manager
176spec:
177 interval: 1h
178 chartRef:
179 kind: OCIRepository
180 name: cert-manager-chart
181 install:
182 strategy:
183 name: RetryOnFailure
184 retryInterval: 5m
185 upgrade:
186 strategy:
187 name: RetryOnFailure
188 retryInterval: 5m
189 values:
190 crds:
191 enabled: true
192```
193
194For HTTPS Helm repositories use `HelmRepository` + `HelmRelease` with `spec.chart.spec`
195(`chart`, `version: "3.x"`, `sourceRef`) instead of `chartRef` — see `references/helmrelease.md`.
196
197### 3. FluxInstance with OCI Sync (Gitless GitOps)
198
199```yaml
200apiVersion: fluxcd.controlplane.io/v1
201kind: FluxInstance
202metadata:
203 name: flux
204 namespace: flux-system
205spec:
206 distribution:
207 version: "2.x"
208 registry: "ghcr.io/fluxcd"
209 components:
210 - source-controller
211 - source-watcher
212 - kustomize-controller
213 - helm-controller
214 - notification-controller
215 cluster:
216 type: kubernetes
217 size: medium
218 multitenant: true
219 tenantDefaultServiceAccount: flux
220 networkPolicy: true
221 sync:
222 kind: OCIRepository
223 url: "oci://ghcr.io/my-org/fleet-manifests"
224 ref: "latest"
225 path: "clusters/production"
226 pullSecret: "registry-auth"
227```
228
229### 4. ResourceSet for Multi-Component Orchestration
230
231A `ResourceSet` lists `spec.inputs` (e.g. `tenant`/`environment` pairs) and `spec.resources`
232templates that reference them with `<< inputs.tenant >>`; each input renders its own Namespace,
233source and Kustomization/HelmRelease. For the full example and the multi-tenant pattern —
234per-tenant ServiceAccount + RoleBinding, `serviceAccountName` impersonation, `dependsOn`,
235and the `reconcileEvery` annotation — load `references/resourcesets.md`.
236
237### 5. Image Automation
238
239- **Git-based** — `ImageRepository` + `ImagePolicy` + `ImageUpdateAutomation` commit tag
240 bumps to Git via `$imagepolicy` YAML markers; requires `image-reflector-controller` and
241 `image-automation-controller`. Use when PR-based approval of bumps is required or Git must
242 record every deployed version. Load `references/image-automation.md`.
243- **Gitless** — `ResourceSet` + `ResourceSetInputProvider` (`type: OCIArtifactTag`) re-renders
244 the downstream `HelmRelease`/`Kustomization` without touching Git: no bot credentials, no poll
245 lag, no extra controllers. Recommended default for Flux Operator; best when the tag lives in
246 Helm values or differs per cluster. Load `references/gitless-image-automation.md`.
247
248### 6. Notifications
249
250`Provider` + `Alert` (`v1beta3`) for outgoing notifications, `Receiver` (`v1`) for incoming
251webhooks. For Slack, GitHub commit status, webhook receivers, and all provider types,
252load `references/notifications.md`.
253
254## Common Mistakes
255
256**Wrong template delimiters:**
257- ResourceSet uses `<< inputs.field >>` — NOT `{{ .inputs.field }}` or `{{ inputs.field }}`
258- Go templates `{{ }}` are only used in ImageUpdateAutomation `.spec.git.commit.messageTemplate`
259
260**Mutual exclusivity:**
261- HelmRelease: `spec.chart.spec` and `spec.chartRef` are mutually exclusive
262- FluxInstance: only one per cluster, must be named `flux`
263
264**HelmRelease strategy fields:**
265- Install/upgrade strategy is at `spec.install.strategy.name` and `spec.upgrade.strategy.name`
266- Always use `RetryOnFailure` — it retries without rollback or uninstall, avoiding downtime
267- Do not use `RemediateOnFailure` or `spec.install.remediation` / `spec.upgrade.remediation`
268
269**OCIRepository for Helm charts:**
270- Set `layerSelector` (`mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"`, `operation: copy`) to extract the chart, as in pattern 2.
271
272**Jobs managed by a ResourceSet:**
273- Job specs are immutable — annotate the Job with `fluxcd.controlplane.io/force: enabled` so a changed spec (new image tag) recreates it instead of failing the apply; add `fluxcd.controlplane.io/recreateOnFailure: enabled` only for idempotent Jobs.
274- Never set `ttlSecondsAfterFinished` — the operator re-applies the TTL-deleted Job as drift and the migration runs again.
275- Set `spec.wait: true` on a stepped ResourceSet, otherwise the final step is not health-checked.
276
277**Post-build substitution pitfalls:**
278- `substituteFrom` only resolves ConfigMaps/Secrets in the Kustomization's own namespace — copy cluster variables into tenant namespaces with `fluxcd.controlplane.io/copyFrom` (ResourceSet) rather than referencing `flux-system` from elsewhere.
279- Kustomize `spec.images[].name` must match a plain image reference in the manifests (`image: frontend`); image rewriting runs at build time, before `${var}` substitution.
280- A substituted value must not start with a YAML indicator (`>`, `|`, `*`, `&`, `[`, `{`, `%`, `@`) — kustomize drops the surrounding quotes, so a semver range like `>=1.0.0` yields invalid YAML. Use `x`, `1.x`, `~1.2.0`, `^1.2.0` or `x || >=0.0.0-0`.
281
282**Drift control — pick the right knob:**
283- Kustomization `spec.ignore` — exclude specific JSON-pointer fields from drift detection/apply (e.g. HPA `replicas`). Distinct from the `kustomize.toolkit.fluxcd.io/ssa: Ignore` annotation, which skips a whole object.
284- HelmRelease `spec.driftDetection.ignore` — the HelmRelease equivalent, only active when `driftDetection.mode` is `warn`/`enabled`.