Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Chapter 5Name in the course: Flux getting started

Deploy apps with Flux

Flux is a set of small controllers. flux bootstrap installs them and stores their own config in Git — so Flux manages itself. Sources (Git, Helm, OCI) are pulled; Kustomizations and HelmReleases apply them.

  • 4 Lessons
  • 7 Commands

$ run as a normal user# run as root (or with sudo)

5.1

Bootstrap Flux

One command installs Flux, creates (or uses) a repository, and commits the Flux manifests into it.

curl -s https://fluxcd.io/install.sh | sudo bash
export GITHUB_TOKEN=ghp_...
flux check --pre
flux bootstrap github --owner=s0sta --repository=fleet --branch=main --path=clusters/lab --personal
flux check
kubectl get pods -n flux-system
ControllerJob
source-controllerPulls Git repositories, Helm repositories, OCI artifacts
kustomize-controllerApplies Kustomize folders
helm-controllerInstalls and upgrades Helm releases
notification-controllerAlerts and incoming webhooks
image-automation (optional)Updates image tags in Git

5.2

Add a source and a Kustomization

A GitRepository tells Flux where to pull; a Kustomization tells it which path to apply, how often, and whether to prune.

flux create source git shop --url=https://github.com/s0sta/shop-deploy --branch=main --interval=1m --export > shop-source.yaml
flux create kustomization shop-prod --source=GitRepository/shop --path=./overlays/prod --prune=true --interval=5m --target-namespace=shop-prod --export > shop-kustomization.yaml
git add . && git commit -m "Add shop to Flux" && git push
flux get sources git
flux get kustomizations

5.3

Install charts with HelmRelease

A HelmRepository source plus a HelmRelease with values.

ingress-nginx.yaml
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata: { name: ingress-nginx, namespace: flux-system }
spec:
  interval: 1h
  url: https://kubernetes.github.io/ingress-nginx
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata: { name: ingress-nginx, namespace: ingress-nginx }
spec:
  interval: 10m
  chart:
    spec:
      chart: ingress-nginx
      version: "4.11.x"
      sourceRef: { kind: HelmRepository, name: ingress-nginx, namespace: flux-system }
  values:
    controller:
      replicaCount: 2

5.4

Operate Flux

Force a sync, pause, and read events.

flux reconcile kustomization shop-prod --with-source
flux suspend kustomization shop-prod
flux resume kustomization shop-prod
flux logs --level=error
flux events
flux tree kustomization shop-prod

Remember

suspend is the emergency brake: Flux stops changing that part, so you can investigate. Always resume (and fix Git) afterwards.

Commands in this lesson

All commands in this chapter