Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

flux

The CLI of Flux CD, a GitOps tool made of Kubernetes controllers that pull from Git and apply the changes.

Niveau
DevSecOps-service
Groep
Git en CI/CD
Root nodig
Nee
Pakket
flux

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

Flux installs controllers into the cluster: the source-controller pulls Git repos, Helm repos and OCI artifacts; the kustomize-controller applies folders; the helm-controller installs charts; the image automation controllers can write new image tags back to Git. Everything is a Kubernetes object (GitRepository, Kustomization, HelmRelease). Flux has no own UI — you use flux and kubectl.

flux bootstrap installs Flux and commits its own config to your Git repo, so Flux manages itself.

Zo schrijf je het

flux bootstrap github --owner USER --repository REPO --path clusters/NAME
flux get|reconcile|suspend|resume KIND NAME

Belangrijkste delen

Commands

check [--pre]
Check the cluster and Flux.
bootstrap github|gitlab|git
Install Flux and connect it to a repo.
create source git NAME
Create a GitRepository source.
create kustomization NAME
Create a Kustomization (apply a folder).
create helmrelease NAME
Create a HelmRelease.
get all|sources|kustomizations|helmreleases
Show status.
reconcile kustomization|source NAME
Sync now.
suspend / resume KIND NAME
Pause / continue syncing.
logs [--level error]
Controller logs.
diff kustomization NAME --path DIR
Show changes before push.
events
Flux events.
export KIND NAME
Print YAML.
uninstall
Remove Flux.

Opties 6

Meest gebruikt

Common flags

--export
Print YAML instead of creating (write it into Git).
-n NS / -A
Namespace / all namespaces.
--interval 1m
How often to check.
--path ./DIR
Folder in the repo.
--prune
Delete removed objects.
--with-source
Reconcile the source first.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Check and bootstrap with GitHub

    flux check --pre
    export GITHUB_TOKEN=github_pat_xxxx
    flux bootstrap github --owner s0sta --repository fleet --branch main --path clusters/home --personal
  2. 2Add an app from another repo (as YAML in Git)

    flux create source git shop --url https://github.com/s0sta/platform --branch main --interval 1m --export > clusters/home/shop-source.yaml
    flux create kustomization shop --source GitRepository/shop --path ./apps/shop/overlays/prod --prune --interval 5m --target-namespace shop --export > clusters/home/shop-kustomization.yaml
    git add clusters/home && git commit -m "Add shop" && git push
  3. 3Watch and force a sync

    flux get kustomizations
    flux reconcile kustomization shop --with-source
    flux get all -A
  4. 4Install a Helm chart with a HelmRelease

    cat clusters/home/podinfo.yaml
    apiVersion: helm.toolkit.fluxcd.io/v2
    kind: HelmRelease
    metadata: { name: podinfo, namespace: podinfo }
    spec:
      interval: 10m
      chart:
        spec:
          chart: podinfo
          version: "6.7.x"
          sourceRef: { kind: HelmRepository, name: podinfo, namespace: flux-system }
      values:
        replicaCount: 2
  5. 5Decrypt SOPS secrets during apply

    cat clusters/home/shop-kustomization.yaml
    spec:
      decryption:
        provider: sops
        secretRef: { name: sops-age }
  6. 6Pause during an incident

    flux suspend kustomization shop
    flux resume kustomization shop
  7. 7Read errors

    flux logs --level error --since 1h
    flux events -n flux-system
  8. 8Preview a change before you push

    flux diff kustomization shop --path ./apps/shop/overlays/prod
  9. 9See which version runs where

    flux get sources git -A
    flux version
  10. 10Export everything for a backup

    flux export source git --all > sources.yaml
    flux export kustomization --all > kustomizations.yaml

Let op

  • The bootstrap token needs repo rights only once; Flux then uses a deploy key.
  • --prune deletes objects you remove from Git — that is the point, but check the path.

Bestanden

clusters/NAME/flux-system/
Flux's own config in your repo.

Tips om te onthouden

  • Flux vs Argo CD: Flux is CLI/controllers only; Argo CD has a strong UI and multi-cluster view. Learn one well.

Exitcodes

0Success.
1Error.