Flux – Helm Release
Flux kann Helm Charts automatisch deployen und aktualisieren, sobald sich das Git-Repository ändert.
GitRepository
github-gitrepository.yaml – teilt Flux mit, wo die Helm Charts liegen:
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: github
spec:
interval: 1m
url: https://github.com/trutzio/kubernetes-tutorial.git
ref:
branch: main
ignore: |
# alles ausschließen
/*
# nur das Helm-Verzeichnis einschließen
!/src/apps/rolldice/helm/
HelmRelease
rolldice-helmrelease.yaml – definiert das Deployment der rolldice-App:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: rolldice
spec:
interval: 1m
chart:
spec:
chart: src/apps/rolldice/helm/rolldice
sourceRef:
kind: GitRepository
name: github
Befehle
cd src/flux
kubectl apply -f github-gitrepository.yaml
flux get sources git -n default
kubectl get gitrepositories
kubectl apply -f rolldice-helmrelease.yaml
flux get helmreleases -n default
kubectl get helmreleases
kubectl describe helmrelease/rolldice
kubectl get all -l app.kubernetes.io/name=rolldice
kubectl logs -l app.kubernetes.io/name=rolldice
Automatisches Update
Neue Version in Git pushen (z.B. appVersion in Chart.yaml auf 1.0.1 erhöhen):
git add .
git commit -m "chore: bump rolldice to 1.0.1"
git push
# Flux erkennt die Änderung und aktualisiert das Deployment automatisch
helm ls # Flux verwaltet den Helm Release
# http://apps.trutz.cloud/rolldice im Browser aufrufen