diff --git a/content/en/flux/guides/helmreleases.md b/content/en/flux/guides/helmreleases.md index 76048b0a4..7a6be59f6 100644 --- a/content/en/flux/guides/helmreleases.md +++ b/content/en/flux/guides/helmreleases.md @@ -307,8 +307,31 @@ resource is garbage collected by the helm-controller. It is possible to use Kustomize [ConfigMap generator](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/) to trigger a Helm release upgrade every time the encoded values change. -First create a `kustomizeconfig.yaml` for Kustomize to be able to patch -`ConfigMaps` referenced in `HelmRelease` manifests: +{{% alert color="info" title="Folder" %}} +The following files are all created in the same folder, fetched through a Flux Kustomization. +{{% /alert %}} + +First, create a `kustomization.yaml` that generates the `ConfigMap`: + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: podinfo +resources: + - namespace.yaml + - repository.yaml + - release.yaml +configMapGenerator: + - name: podinfo-values + files: + - values.yaml=my-values.yaml +configurations: + - kustomizeconfig.yaml +``` + +Notice this references the configuration `kustomizeconfig.yaml`, used to indicate to Kustomize +where to find `ConfigMaps` in `HelmRelease` manifests (under the key `spec/valuesFrom/name`) when using +[nameReference](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs#name-reference-transformer): ```yaml nameReference: @@ -319,7 +342,7 @@ nameReference: kind: HelmRelease ``` -Create a `HelmRelease` definition that references a `ConfigMap`: +Finally, create the `HelmRelease` definition that references the generated `ConfigMap`: ```yaml apiVersion: helm.toolkit.fluxcd.io/v2 @@ -341,24 +364,6 @@ spec: name: podinfo-values ``` -Create a `kustomization.yaml` that generates the `ConfigMap` using our kustomize config: - -```yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -namespace: podinfo -resources: - - namespace.yaml - - repository.yaml - - release.yaml -configMapGenerator: - - name: podinfo-values - files: - - values.yaml=my-values.yaml -configurations: - - kustomizeconfig.yaml -``` - When [kustomize-controller](../components/kustomize/_index.md) reconciles the above manifests, it will generate a unique name of the `ConfigMap` every time `my-values.yaml` content is updated in Git: