From 7b2717c50c01643988d22c0214d6ec2f8cbbcca2 Mon Sep 17 00:00:00 2001 From: Somtochi Onyekwere Date: Tue, 14 Feb 2023 00:03:46 +0100 Subject: [PATCH 1/3] update explanation for flux create command Signed-off-by: Somtochi Onyekwere --- content/en/flux/use-cases/helm.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/content/en/flux/use-cases/helm.md b/content/en/flux/use-cases/helm.md index 1b7b318ac..c0b3a44b1 100644 --- a/content/en/flux/use-cases/helm.md +++ b/content/en/flux/use-cases/helm.md @@ -48,21 +48,21 @@ helm install my-traefik traefik/traefik \ Flux client: ```sh -flux create source helm traefik --url https://helm.traefik.io/traefik --namespace traefik +flux create source helm traefik --url https://helm.traefik.io/traefik --namespace traefik --export > /flux/boot/traefik/helmrepo.yaml flux create helmrelease my-traefik --chart traefik \ --source HelmRepository/traefik \ --chart-version 9.18.2 \ - --namespace traefik + --namespace traefik \ + --export > /flux/boot/traefik/helmrepo.yaml ``` -The main difference is that the Flux client will not imperatively create resources in the cluster. -Instead, these commands create Custom Resource *files*, which are committed to version control -as instructions only (note: you may use the `--export` flag to manage any file edits with -finer grained control before pushing to version control). -Separately, the Flux Helm Controller automatically reconciles these instructions -with the running state of your cluster based on your configured rules. +These commands save the YAML for the Flux helm custom resources to a file which can be edited and pushed to git. +When these resources are pushed to a repository that Flux watches, Flux applies them on the cluster and the Flux +Helm Controller automatically reconciles these instructions with the running state of your cluster based on your +configured rules. Alternatively, you can run the commands without the `--export` command and this will apply the +resources directly on your cluster. -Let's check out what the Custom Resource files look like: +Let’s check out what the Custom Resource files look like: ```yaml # /flux/boot/traefik/helmrepo.yaml @@ -87,6 +87,7 @@ spec: chart: spec: chart: traefik + reconcileStrategy: ChartVersion sourceRef: kind: HelmRepository name: traefik From 40e64728c6fcd4f7e5a48c6262e12bf865cc5ec4 Mon Sep 17 00:00:00 2001 From: Somtochi Onyekwere Date: Thu, 16 Feb 2023 10:54:00 +0100 Subject: [PATCH 2/3] Add flux installation pre requisite Signed-off-by: Somtochi Onyekwere --- content/en/flux/use-cases/helm.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/content/en/flux/use-cases/helm.md b/content/en/flux/use-cases/helm.md index c0b3a44b1..6b727237d 100644 --- a/content/en/flux/use-cases/helm.md +++ b/content/en/flux/use-cases/helm.md @@ -31,6 +31,13 @@ Additional benefits Flux adds to Helm include: - Automated drift detection between the desired and actual state of your operations - Automated responses to that drift, including reconciliation, notifications, and unified logging +## Prerequisites + +To follow along you'll need a Kubernetes cluster with Flux installed on it. +Please see the [get started guide](../get-started/index.md) +or the [installation guide](../installation/). + + ## Getting Started The simplest way to explain is by example. @@ -47,25 +54,26 @@ helm install my-traefik traefik/traefik \ Flux client: +Clone your bootstrap repository to your local machine and create a `traefik` directory in your bootstrap path. + ```sh -flux create source helm traefik --url https://helm.traefik.io/traefik --namespace traefik --export > /flux/boot/traefik/helmrepo.yaml +flux create source helm traefik --url https://helm.traefik.io/traefik --namespace traefik --export > traefik/helmrepo.yaml flux create helmrelease my-traefik --chart traefik \ --source HelmRepository/traefik \ --chart-version 9.18.2 \ --namespace traefik \ - --export > /flux/boot/traefik/helmrepo.yaml + --export > traefik/helmrepo.yaml ``` -These commands save the YAML for the Flux helm custom resources to a file which can be edited and pushed to git. -When these resources are pushed to a repository that Flux watches, Flux applies them on the cluster and the Flux -Helm Controller automatically reconciles these instructions with the running state of your cluster based on your -configured rules. Alternatively, you can run the commands without the `--export` command and this will apply the -resources directly on your cluster. +These commands save the YAML for the Flux helm custom resources to the specified fil. When these resources are pushed to the +repository, Flux applies them on the cluster and the Flux Helm Controller automatically reconciles these instructions +with the running state of your cluster based on your configured rules. Alternatively, you can run the commands without +the `--export` command and this will apply the resources directly on your cluster. Let’s check out what the Custom Resource files look like: ```yaml -# /flux/boot/traefik/helmrepo.yaml +# traefik/helmrepo.yaml apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository metadata: @@ -77,7 +85,7 @@ spec: ``` ```yaml -# /flux/boot/traefik/helmrelease.yaml +# traefik/helmrelease.yaml apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: From d2b5fc5e63b8d0542244c0685088264a5e57aae7 Mon Sep 17 00:00:00 2001 From: Somtochi Onyekwere Date: Tue, 21 Feb 2023 00:26:29 +0100 Subject: [PATCH 3/3] Use flagger helm chart Signed-off-by: Somtochi Onyekwere --- content/en/flux/use-cases/helm.md | 61 +++++++++++++++++-------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/content/en/flux/use-cases/helm.md b/content/en/flux/use-cases/helm.md index 6b727237d..ec861f0ed 100644 --- a/content/en/flux/use-cases/helm.md +++ b/content/en/flux/use-cases/helm.md @@ -46,26 +46,29 @@ Lets translate imperative Helm commands to Flux Helm Controller Custom Resources Helm client: ```sh -helm repo add traefik https://helm.traefik.io/traefik -helm install my-traefik traefik/traefik \ - --version 9.18.2 \ - --namespace traefik +helm repo add flagger https://flagger.app +helm install my-flagger flagger/flagger \ + --version 1.28.0 ``` Flux client: -Clone your bootstrap repository to your local machine and create a `traefik` directory in your bootstrap path. +Clone your bootstrap repository to your local machine and create a `flagger` directory in your bootstrap path. +```sh +git clone +cd +mkdir flagger +``` ```sh -flux create source helm traefik --url https://helm.traefik.io/traefik --namespace traefik --export > traefik/helmrepo.yaml -flux create helmrelease my-traefik --chart traefik \ - --source HelmRepository/traefik \ - --chart-version 9.18.2 \ - --namespace traefik \ - --export > traefik/helmrepo.yaml +flux create source helm flagger --url https://flagger.app --export > flagger/helmrepo.yaml +flux create helmrelease flagger --chart flagger \ + --source HelmRepository/flagger \ + --chart-version '*' \ + --export > flagger/helmrelease.yaml ``` -These commands save the YAML for the Flux helm custom resources to the specified fil. When these resources are pushed to the +These commands save the YAML for the Flux helm custom resources to the specified file. When these resources are pushed to the repository, Flux applies them on the cluster and the Flux Helm Controller automatically reconciles these instructions with the running state of your cluster based on your configured rules. Alternatively, you can run the commands without the `--export` command and this will apply the resources directly on your cluster. @@ -73,33 +76,33 @@ the `--export` command and this will apply the resources directly on your clust Let’s check out what the Custom Resource files look like: ```yaml -# traefik/helmrepo.yaml +# flagger/helmrepo.yaml apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository metadata: - name: traefik - namespace: traefik + name: flagger + namespace: flux-system spec: interval: 1m0s - url: https://helm.traefik.io/traefik + url: https://flagger.app ``` ```yaml -# traefik/helmrelease.yaml +# flagger/helmrelease.yaml apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: - name: my-traefik - namespace: traefik + name: flagger + namespace: flux-system spec: chart: spec: - chart: traefik + chart: flagger reconcileStrategy: ChartVersion sourceRef: kind: HelmRepository - name: traefik - version: 9.18.2 + name: flagger + version: '*' interval: 1m0s ``` @@ -121,20 +124,21 @@ The Helm client allows this by imperatively specifying override values with `--s and in additional `--values` files. For example: ```sh -helm install my-traefik traefik/traefik --set service.type=ClusterIP +helm install my-flagger flagger/flagger --set resource.limit.memory=1Gi ``` and ```sh -helm install my-traefik traefik/traefik --values ci/kind-values.yaml +helm install my-flagger flagger/flagger --values ci/kind-values.yaml ``` where `ci/kind-values.yaml` contains: ```yaml -service: - type: ClusterIP +resource: + limit: + memory: 1Gi ``` Flux Helm Controller allows these same YAML values overrides on the `HelmRelease` CRD. @@ -143,8 +147,9 @@ These can be declared directly in `spec.values`: ```yaml spec: values: - service: - type: ClusterIP + resource: + limit: + memory: 1Gi ``` and defined in `spec.valuesFrom` as a list of `ConfigMap` and `Secret` resources from which to draw values,