Flux

Installation

Für die Installation muss zunächst der flux Client installiert sein.

curl -s https://fluxcd.io/install.sh | sudo bash

Bei Benutzung eines GitLab wird ein Access Token mit Schreibrechten auf das Repository oder die Gruppe benötigt. Sinnvollerweise kann dieser in der Datei $HOME/.gitlab hinterlegt sein.

Danach kann flux mit den benötigen Umgebungswerten gestartet werden.

export GITLAB_TOKEN="$(<.gitlab)"
export GITLAB_HOSTNAME="git.mylinuxtime.de"
export GITLAB_OWNER="kubernetes/flux" # GitLab Gruppe für das Repository
export GITLAB_REPOSITORY="prod-kube"  # Repository in der Gruppe
export GITLAB_BRANCH="main"           # zu benutzender Branch
export GITLAB_PATH="prod"             # Pfad innerhalb des Repositories

flux bootstrap gitlab --owner $GITLAB_OWNER \
                      --repository $GITLAB_REPOSITORY \
                      --branch $GITLAB_BRANCH \
                      --path $GITLAB_PATH \
                      --token-auth \
                      --hostname $GITLAB_HOSTNAME

Es wird automatisch das benötigte Repository angelegt und die Dateien für flux abgelegt.

Im Cluster werden die benötigten CRDs und Deployments angelegt und gestartet.

Update

Ob eine neuere Version für ein Update zur Verfügung steht kann über das Subkommando check geprüft werden.

$ flux check
► checking prerequisites
✗ flux 2.4.0 <2.5.0 (new CLI version is available, please upgrade)
✔ Kubernetes 1.30.4+rke2r1 >=1.28.0-0
► checking version in cluster
✔ distribution: flux-v2.4.0
✔ bootstrapped: true
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v1.1.0
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v1.4.0
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v1.4.0
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v1.4.1
► checking crds
✔ alerts.notification.toolkit.fluxcd.io/v1beta3
✔ buckets.source.toolkit.fluxcd.io/v1
✔ gitrepositories.source.toolkit.fluxcd.io/v1
✔ helmcharts.source.toolkit.fluxcd.io/v1
✔ helmreleases.helm.toolkit.fluxcd.io/v2
✔ helmrepositories.source.toolkit.fluxcd.io/v1
✔ kustomizations.kustomize.toolkit.fluxcd.io/v1
✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2
✔ providers.notification.toolkit.fluxcd.io/v1beta3
✔ receivers.notification.toolkit.fluxcd.io/v1
✔ all checks passed

Die Komponenten können dann innerhalb des Repositories aktualisiert werden.

$ flux install --export > flux-system/gotk-components.yaml
$ git add flux-system/gotk-components.yaml
$ git commit -m "Update gotk components"
$ git push