|
| 1 | +# Helm interoperability with Flux |
| 2 | + |
| 3 | +[Flux AIO](flux-aio.md) can be used as a bridge between Timoni and Helm, enabling Timoni |
| 4 | +to orchestrate Helm chart deployments by leveraging Flux's declarative Helm APIs |
| 5 | +such as `HelmRepository` and `HelmRelease` kinds. |
| 6 | + |
| 7 | +With Flux, Timoni users can take full advantage of existing Helm charts. |
| 8 | +Timoni [Bundles](bundle.md) can refer to Helm charts hosted on Helm HTTPS and OCI repositories, |
| 9 | +and supports setting Helm release values in the same way you would do for Timoni instances. |
| 10 | + |
| 11 | +## Install Flux helm-controller |
| 12 | + |
| 13 | +Install Flux helm-controller on a Kubernetes cluster with: |
| 14 | + |
| 15 | +```cue |
| 16 | +bundle: { |
| 17 | + apiVersion: "v1alpha1" |
| 18 | + name: "flux-aio" |
| 19 | + instances: { |
| 20 | + "flux": { |
| 21 | + module: url: "oci://ghcr.io/stefanprodan/modules/flux-aio" |
| 22 | + namespace: "flux-system" |
| 23 | + values: { |
| 24 | + controllers: { |
| 25 | + helm: enabled: true |
| 26 | + kustomize: enabled: false |
| 27 | + notification: enabled: false |
| 28 | + } |
| 29 | + hostNetwork: false |
| 30 | + securityProfile: "privileged" |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +Apply the bundle with: |
| 38 | + |
| 39 | +```shell |
| 40 | +timoni bundle apply -f flux-aio.cue |
| 41 | +``` |
| 42 | + |
| 43 | +## Deploy Helm charts |
| 44 | + |
| 45 | +To deploy Helm charts on clusters with Flux installed, you'll be using |
| 46 | +the [flux-helm-release](https://github.com/stefanprodan/flux-aio/tree/main/modules/flux-helm-release) |
| 47 | +Timoni module. This module generates Flux `HelmRepository` and `HelmRelease` objects and allows |
| 48 | +the configuration of the Helm repository HTTP/S or OCI URL, auth token, chart name, and Helm release values. |
| 49 | + |
| 50 | +### Public repositories |
| 51 | + |
| 52 | +Example of deploying `cert-manager` and `ingress-nginx` Helm charts to a Kubernetes cluster: |
| 53 | + |
| 54 | +```cue |
| 55 | +bundle: { |
| 56 | + apiVersion: "v1alpha1" |
| 57 | + name: "cluster-addons" |
| 58 | + instances: { |
| 59 | + "cert-manager": { |
| 60 | + module: url: "oci://ghcr.io/stefanprodan/modules/flux-helm-release" |
| 61 | + namespace: "cert-manager" |
| 62 | + values: { |
| 63 | + repository: url: "https://charts.jetstack.io" |
| 64 | + chart: { |
| 65 | + name: "cert-manager" |
| 66 | + version: "1.x" |
| 67 | + } |
| 68 | + helmValues: { |
| 69 | + installCRDs: true |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + "ingress-nginx": { |
| 74 | + module: url: "oci://ghcr.io/stefanprodan/modules/flux-helm-release" |
| 75 | + namespace: "ingress-nginx" |
| 76 | + values: { |
| 77 | + repository: url: "https://kubernetes.github.io/ingress-nginx" |
| 78 | + chart: { |
| 79 | + name: "ingress-nginx" |
| 80 | + version: "4.x" |
| 81 | + } |
| 82 | + helmValues: { |
| 83 | + controller: service: type: "NodePort" |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +Apply the bundle with: |
| 92 | + |
| 93 | +```shell |
| 94 | +timoni bundle apply -f cluster-addons.cue |
| 95 | +``` |
| 96 | + |
| 97 | +Timoni will create the Flux Helm repositories, will wait for Flux to install |
| 98 | +the `cert-manager` release, then will proceed with the `ingress-nginx` installation. |
| 99 | + |
| 100 | +After the releases are installed, Flux will scan for new chart versions every hour, |
| 101 | +and will upgrade a release if a new chart version is found. To disable the automated |
| 102 | +upgrade, you can set a fix version for each chart under `values: chart: version`. |
| 103 | + |
| 104 | +### Private repositories |
| 105 | + |
| 106 | +When using Helm charts from a private Helm HTTPS or OCI repository, you can |
| 107 | +provide the auth credentials in the Bundle using Timoni runtime attributes. |
| 108 | + |
| 109 | +Example of deploying the `podinfo` Helm chart from GitHub Container Registry |
| 110 | +using a GitHub PAT for auth: |
| 111 | + |
| 112 | +```cue |
| 113 | +bundle: { |
| 114 | + apiVersion: "v1alpha1" |
| 115 | + name: "podinfo" |
| 116 | + instances: { |
| 117 | + "podinfo": { |
| 118 | + module: url: "oci://ghcr.io/stefanprodan/modules/flux-helm-release" |
| 119 | + namespace: "podinfo" |
| 120 | + values: { |
| 121 | + repository: { |
| 122 | + url: "oci://ghcr.io/stefanprodan/charts" |
| 123 | + auth: { |
| 124 | + username: "flux" |
| 125 | + password: string @timoni(runtime:string:GITHUB_TOKEN) |
| 126 | + } |
| 127 | + } |
| 128 | + chart: { |
| 129 | + name: "podinfo" |
| 130 | + version: "*" |
| 131 | + } |
| 132 | + helmValues: { |
| 133 | + logLevel: "info" |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +Assuming the `GITHUB_TOKEN` is set in your environment, apply the bundle |
| 142 | +using the `--runtime-from-env` flag and Timoni will fill in the token value: |
| 143 | + |
| 144 | +```shell |
| 145 | +timoni bundle apply -f podinfo.cue --runtime-from-env |
| 146 | +``` |
| 147 | + |
| 148 | +Timoni will create a Kubernetes Secret with the Helm credentials, and will |
| 149 | +configure Flux to use the Secret when pulling the Helm OCI charts from the |
| 150 | +container registry. |
0 commit comments