Zum Inhalt springen
Trainingslager IT-Trainingslager

Anhang A: Spickzettel

Alles auf einen Blick, sortiert nach Thema.

Adressen im Lab

Was Wo
notes (prod, Namespace notes) http://<VM-IP>:30080
notes (dev, Namespace notes-dev) http://<VM-IP>:30081
notes-helm http://<VM-IP>:30090
Team blau (Deployment, NotesApp) :30092, :30094
Team grün (NotesApp) :30095
Registry im Cluster localhost:30500 (VM), registry.registry.svc.cluster.local:5000 (Cluster)
Receiver http://<VM-IP>:30900/hook/…
Schlüssel und Tokens ~/flux-lab/age-2027.agekey, ~/flux-lab/webhook.token, ~/.github-token

Installation und Upgrade

flux check --pre
flux bootstrap github --owner=$GITHUB_USER --repository=flux-fleet \
  --branch=main --path=clusters/lab --personal --private=true \
  --components-extra=image-reflector-controller,image-automation-controller \
  --read-write-key
flux check
flux uninstall --dry-run --silent
  • Upgrade: neue CLI installieren, denselben bootstrap noch einmal ausführen.
  • Deploy-Key neu erzeugen: kubectl -n flux-system delete secret flux-system, dann bootstrap.
  • Patches in clusters/<name>/flux-system/kustomization.yaml überleben jeden Bootstrap.

Objekte erzeugen

Immer mit --export > datei.yaml, damit Git die Wahrheit bleibt.

flux create source git NAME --url=… --tag-semver="6.x" --export
flux create source oci NAME --url=oci://… --tag-semver="0.x" [--insecure] \
  [--layer-selector=application/vnd.cncf.helm.chart.content.v1.tar+gzip:copy] --export
flux create source helm NAME --url=https://… --export
flux create kustomization NAME --source=GitRepository/flux-system --path=./… \
  --prune=true --interval=10m [--wait=true --timeout=2m] [--depends-on=X] \
  [--target-namespace=NS] [--service-account=SA] --export
flux create helmrelease NAME --chart-ref=OCIRepository/X.NS --values=werte.yaml --export
flux create helmrelease NAME --source=HelmRepository/X --chart=C --chart-version="1.x" --export
flux create image repository NAME --image=ghcr.io/… --export
flux create image policy NAME --image-ref=X --select-semver=">=1.0.0" --export
flux create image update NAME --git-repo-ref=flux-system --git-repo-path=./clusters/lab \
  --checkout-branch=main --push-branch=main --author-name=… --author-email=… --export
flux create alert-provider NAME --type=generic|github|slack --address=… --export
flux create alert NAME --provider-ref=X --event-severity=info|error \
  --event-source="Kustomization/*" --export
flux create receiver NAME --type=github --event=push --secret-ref=X \
  --resource=GitRepository/flux-system --export
flux create tenant NAME --with-namespace=NAME --export

Ansehen und Fehler finden

flux get all -A
flux get all -A --status-selector ready=false
flux get kustomizations | helmreleases | sources all | image policy
flux events --for Kustomization/NAME
flux logs --kind=Kustomization --name=NAME --since=10m
flux trace deployment NAME -n NS
flux tree kustomization NAME
flux stats -A
flux build kustomization NAME --path ./…
flux diff kustomization NAME --path ./… --kustomization-file clusters/lab/NAME.yaml
flux reconcile kustomization NAME --with-source
flux suspend | resume kustomization NAME

Wichtige Felder

Objekt Feld Wirkung Tag
Kustomization prune Gelöschtes aus Git entfernen 2
Kustomization wait, timeout erst bereit, wenn Objekte bereit sind 4
Kustomization dependsOn Reihenfolge 4
Kustomization postBuild.substitute(From) Variablen ${X}, ${X:=std} 4
Kustomization targetNamespace Namespace setzen 3
Kustomization decryption SOPS entschlüsseln 8
Kustomization serviceAccountName als dieser ServiceAccount anwenden 12
GitRepository ignore nur Teile holen 3
HelmRelease valuesFrom Werte aus ConfigMap/Secret 6
HelmRelease driftDetection.mode enabled oder warn 6, 7
HelmRelease upgrade.remediation zurückrollen 7
HelmRelease test.enable Helm-Tests 7
ImageRepository exclusionList Tags beim Scan ignorieren 9
Objekt im Cluster kustomize.toolkit.fluxcd.io/prune: disabled nie prunen 4
ConfigMap reconcile.fluxcd.io/watch: Enabled Änderungen sofort übernehmen 5

Meldungen und was sie bedeuten

Meldung Ursache Tag
Write access to repository not granted Token ohne Contents 1
GET …/keys: 403 Token ohne Administration 1
refusing to allow a Personal Access Token to create or update workflow Token ohne Workflows 13
dry-run failed … expected numeric … got string Typfehler im Manifest 2
health check failed after 2m0s: timeout waiting for Pods werden nicht bereit 4
dependency '…' revision is not up to date Abhängigkeit noch nicht fertig 4
variable not set (strict mode) Variable fehlt 4
configmaps "…" not found (HelmRelease) Hash-Name ohne nameReference 6
RetriesExceeded (Stalled) Remediation aufgegeben, neues Chart nötig 7
ENC[AES256_GCM,… im Cluster-Secret decryption fehlt 8, 15
Failed to get the data key falscher age-Schlüssel 8
repository up-to-date trotz Abweichung alter Push-Branch 10, 15
payload signature check failed Zeilenumbruch im Token 11, 15
User "system:serviceaccount:…:default" cannot … serviceAccountName fehlt (Lockdown) 12, 14, 15
Kustomization object '…' not found Datei fehlt unter resources 14, 15

Reihenfolgen

  • SOPS einführen: erst decryption in die Kustomization, dann verschlüsseln.
  • Objekt zwischen Kustomizations verschieben: erst prune: disabled setzen und anwenden, dann verschieben.
  • age-Schlüssel wechseln: neuen Schlüssel ins Cluster-Secret (beide), updatekeys, pushen, alten Schlüssel entfernen.
  • Lockdown: erst allen Objekten der Plattform einen ServiceAccount geben, dann die Controller-Optionen setzen.
  • Plattform-APIs: Werkzeug (kro) → API (kro-apis) → Mandanten (tenants).