Kubernetes/Progressive Delivery Flux and Flagger

From Ever changing code
Jump to navigation Jump to search

Flux v2

Flux v2 Documentation

Flux v2 architecture

ClipCapIt-210524-232835.PNG

Flux v2 - Webhooks and notifications

ClipCapIt-210524-233028.PNG

Install FluxCD Cli flux

Note: fluxctl was a cli client for version Flux v1.

# Install or upgrade using official install.sh (option-1)
export FLUX_VERSION=2.7.5; curl -s https://fluxcd.io/install.sh | sudo -E bash
curl -s https://fluxcd.io/install.sh | sudo bash # latest

# Version check
flux version 
flux: v2.7.5
distribution: flux-v2.7.5
helm-controller: v1.4.5
kustomize-controller: v1.7.3
notification-controller: v1.7.5
source-controller: v1.7.4


# enable completions in ~/.bash_profile
. <(flux completion bash)

# Pre check
flux check --pre
► checking prerequisites
✗ Kubernetes version v1.27.16 does not match >=1.32.0-0

# Docker images
docker pull fluxcd/fluxctl:1.24.3
docker pull ghcr.io/fluxcd/flux-cli:1.24.3 # does not work

Cluster bootstrap

FluxCDv2 bootstrap process is installing the Flux onto a cluster and stores(commits) its own manifests to a Git repository.


FLUX_GIT_USERNAME=my-git-username
FLUX_GIT_EMAIL=my-git-email@example.com
flux bootstrap git \
  --author-email=$FLUX_GIT_EMAIL \
  --url=ssh://git@github.com/$FLUX_GIT_USERNAME/gitops-istio \
  --branch=main \
  --path=clusters/my-cluster

At bootstrap, Flux generates an SSH key and prints the public key. In order to sync your cluster state with git you need to copy the public key and create a deploy key with write access on your GitHub repository. On GitHub go to Settings > Deploy keys click on Add deploy key, check Allow write access, paste the Flux public key and click Add key.


Dev installation does not stores its own configuration state in Git repository
# option 1
flux install # install and upgrade
flux install \
--namespace=flux-system \
--network-policy=false \
--components=source-controller

# option 2
kubectl apply -f https://github.com/fluxcd/flux2/releases/latest/download/install.yaml
kustomize build https://github.com/fluxcd/flux2/manifests/install?ref=main | kubectl apply -f- # Upgrade

# Register Git repositories and reconcile them on your cluster:
flux create source git podinfo \
  --url=https://github.com/stefanprodan/podinfo \
  --tag-semver=">=4.0.0" \
  --interval=1m

flux create kustomization podinfo-default \
  --source=podinfo \
  --path="./kustomize" \
  --prune=true \
  --validation=client \
  --interval=10m \
  --health-check="Deployment/podinfo.default" \
  --health-check-timeout=2m

# Register Helm repositories and create Helm releases:
flux create source helm bitnami \
  --interval=1h \
  --url=https://charts.bitnami.com/bitnami

flux create helmrelease nginx \
  --interval=1h \
  --release-name=nginx-ingress-controller \
  --target-namespace=kube-system \
  --source=HelmRepository/bitnami \
  --chart=nginx-ingress-controller \
  --chart-version="5.x.x"


Uninstall

flux uninstall --namespace=flux-system

References


Bundle