Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know it before you install
Sources fetch things (GitRepository, OCIRepository, HelmRepository). Kustomizations (Flux objects, not the kustomize file) apply a path from a source to the cluster on an interval. HelmReleases install charts. Each is reconciled by its controller: source-controller, kustomize-controller, helm-controller, notification-controller (and image automation controllers if you want them).
| Item | Value |
|---|---|
| CLI | flux |
| Namespace | flux-system |
| Git layout | clusters/<cluster>/ (Flux's own config and the entry Kustomizations) |
| Objects | GitRepository, Kustomization, HelmRepository, HelmRelease, Alert, ImagePolicy … |
| Secrets in Git | SOPS (age or cloud KMS), decrypted by kustomize-controller |
Install the CLI (RHEL and Ubuntu)
Bootstrap the cluster with GitHub
Bootstrap creates (or uses) a repository, commits Flux's manifests to clusters/prod, installs Flux, and makes Flux watch that path. Use a token with repo rights (or a GitHub App):
export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
flux bootstrap github --owner=ORG --repository=fleet --branch=main --path=clusters/prod --personal=false --read-write-key=false
► connecting to github.com
✔ repository "https://github.com/ORG/fleet" created
✔ reconciled components
✔ all components are healthy
flux check
kubectl -n flux-system get podsFlux makes a read-only deploy key for the repository; the token is only used for the bootstrap. (GitLab: flux bootstrap gitlab; any Git server: flux bootstrap git --url=ssh://….)
First configuration: add an app
A source for the app's deploy repo and a Kustomization that applies ./deploy/prod from it:
flux create source git shop --url=https://github.com/ORG/shop-deploy --branch=main --interval=1m --export > clusters/prod/shop-source.yaml
flux create kustomization shop --source=GitRepository/shop --path="./deploy/prod" --prune=true --interval=5m --target-namespace=shop --wait=true --export > clusters/prod/shop-kustomization.yaml
git add clusters/prod && git commit -m "Add shop" && git push
flux reconcile kustomization flux-system --with-source
flux get kustomizations
NAME REVISION READY MESSAGE
flux-system main@sha1:4f2c1a9e True Applied revision: main@sha1:4f2c1a9e
shop main@sha1:a81b0c37 True Applied revision: main@sha1:a81b0c37| Setting | Why |
|---|---|
--prune=true | Objects removed from Git are removed from the cluster. |
--interval | How often Flux checks (add webhooks for instant sync). |
--wait=true | The Kustomization is Ready only when the workloads are healthy. |
| Commit the generated YAML | Everything — even Flux's own config — lives in Git. |
A Helm chart, the GitOps way:
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: jetstack
namespace: flux-system
spec:
interval: 12h
url: https://charts.jetstack.io
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: cert-manager
namespace: cert-manager
spec:
interval: 30m
chart:
spec:
chart: cert-manager
version: "1.19.x"
sourceRef:
kind: HelmRepository
name: jetstack
namespace: flux-system
install:
remediation: { retries: 3 }
upgrade:
remediation: { retries: 3, remediateLastFailure: true }
values:
crds:
enabled: trueSecrets with SOPS
Encrypt Secrets in Git with an age key; Flux decrypts them in the cluster:
age-keygen -o age.agekey
kubectl -n flux-system create secret generic sops-age --from-file=age.agekey=age.agekey
sops --encrypt --age AGE_PUBLIC_KEY --encrypted-regex '^(data|stringData)$' --in-place deploy/prod/db-secret.yamlAdd decryption: {provider: sops, secretRef: {name: sops-age}} to the Kustomization. Keep the age.agekey file out of Git (store it in a password manager / KMS).
Daily use: the commands and the real uses
flux get all -A
flux get sources git
flux get helmreleases -A
flux reconcile kustomization shop --with-source
flux suspend kustomization shop
flux resume kustomization shop
flux logs --level=error --since=1h
flux events -n flux-system
flux tree kustomization shop
flux diff kustomization shop --path ./deploy/prodsuspend stops syncing (for an emergency hotfix); resume starts it again — the cluster then goes back to what Git says.
Real uses at work:
- Many clusters from one "fleet" repo (
clusters/dev,clusters/prod), with sharedinfrastructure/andapps/folders. - Platform add-ons as HelmReleases; app teams deploy by merging to their deploy repo.
- Image automation: Flux updates the image tag in Git when a new version is pushed.
- Alerts to Slack/Teams on failed reconciles (
Provider+Alertobjects).
Make it safe
Security checklist:
- Read-only deploy keys; the bootstrap token short-lived and not stored.
- Branch protection on the fleet repo — Git is production access.
- SOPS for all secrets; the decryption key only in the cluster and a safe store.
- Multi-tenancy: per-team Kustomizations with
serviceAccountNameand limited RBAC. - Pin chart versions (or narrow ranges) and image tags; review changes in pull requests.
- Keep Flux updated (
flux bootstrapagain with the new CLI version).
Update and remove
bash flux-install.sh
flux bootstrap github --owner=ORG --repository=fleet --branch=main --path=clusters/prod
flux uninstall --keep-namespace=falseRunning bootstrap again with a newer CLI upgrades the controllers (and commits the new manifests). flux uninstall removes Flux but leaves your apps running.
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
Kustomization: kustomization path not found | Wrong path in the Kustomization. | Check the folder name in Git; paths start with ./. |
Source: authentication required / unable to clone | Deploy key missing or wrong URL. | flux get sources git; check the key in the repo settings; SSH vs HTTPS URL. |
HelmRelease upgrade retries exhausted | The chart upgrade fails (values, immutable field). | flux logs --kind=HelmRelease; kubectl describe helmrelease; fix values; flux reconcile hr NAME --force. |
| Changes in Git are not applied | Interval not reached, or the Kustomization is suspended. | flux reconcile … --with-source; flux get kustomizations (SUSPENDED?). |
Decryption fails: sops: failed to decrypt | Wrong or missing age key secret. | Check the sops-age secret and the public key used. |
dependency 'flux-system/infra' is not ready | A dependsOn target is failing. | Fix the dependency first; flux tree. |
Next steps
- Quick how-tos: Deploy from Git.
- Command page: flux, Command page: sops.
- GitOps in depth: GitOps summary — Bootstrap Flux, HelmRelease, Image automation.
- At work: Flux — GitOps as controllers. The UI-based tool: Argo CD.
1What does flux bootstrap put in Git?
Flux's own manifests and sync config under the chosen path, so Flux manages itself from Git.
2How do you stop Flux from undoing an emergency hotfix for a while?
flux suspend kustomization NAME — then put the fix in Git and flux resume.