flux2 icon indicating copy to clipboard operation
flux2 copied to clipboard

flux build helmrelease

Open akamac opened this issue 2 years ago • 10 comments

It would be great if flux cli could render kubernetes manifests from HelmRelease locally, so it is possible to run static analysis checks against generated files before committing them into repo.

akamac avatar Jun 04 '22 19:06 akamac

Does anyone know of a way of generating the output of a Flux HelmRelease using other tools or a multi-step process?

MrMarkW avatar Nov 30 '22 20:11 MrMarkW

In addition to flux build helmrelease, it would be nice to have flux diff helmrelease. While the former is handy during the local development stage, the latter could be used in CI/CD to generate PR diff.

vvbogdanov87 avatar Apr 27 '23 21:04 vvbogdanov87

@MrMarkW If It is not too late, here is the process:

  1. Build Flux Kustomization:
flux build kustomization <kustomization_name> --path dev > out/kustomization_out.yaml

In my case kustomization_out.yaml contains 2 YAML manifests HelmRepository and HelmRelease.

  1. Take Helm repository URL and name from HelmRelease and add the Helm repo:
helm repo add <helm_repo_name> <helm_repo_url>
  1. Take the values section from HelmRelease and add it to values.yaml file. After that you will be able to render the chart locally:
helm template <name> <helm_repo_name>/<helm_chart_name> -f out/values.yaml > out/helm_out.yaml
  1. If you have postRenderers section in HelmRelease, you can create kustomization.yaml file similar to this one:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - helm_out.yaml
patchesStrategicMerge:
- patch_1.yaml
- patch_2.yaml
- patch_3.yaml

After that move patches from the postRenderers section to the patch files and render the final result:

 kustomize build out

These steps can be scripted. But I don't see why Flux couldn't do the same. Because it is what it already does.

vvbogdanov87 avatar May 01 '23 16:05 vvbogdanov87

I just created https://github.com/DoodleScheduling/flux-build and came across this issue now, this seems exactly what you are looking for.

raffis avatar May 26 '23 12:05 raffis

Would be great to have this functionality in the official flux cli, for "simple" HelmRelease I've built https://aur.archlinux.org/packages/helmrelease-tools which is quite simple and works surprisingly well 👍

cwrau avatar Jul 07 '23 17:07 cwrau

selfish bump

wibed avatar Aug 02 '23 14:08 wibed

We haven't forgot about this, to enable this feature in the CLI we first have to rewrite helm-controller. This rewrite is tracked in the roadmap under Helm GA. Hopefully we'll have it ready by end of Q3 then we can work on flux build/diff hr.

stefanprodan avatar Aug 02 '23 14:08 stefanprodan

any news on this ? For now: @cwrau how would your tool "helmrelease-tools" work in the described steps by @vvbogdanov87 ? thx

rbcb-bedag avatar Mar 14 '24 15:03 rbcb-bedag

any news on this ? For now: @cwrau how would your tool "helmrelease-tools" work in the described steps by @vvbogdanov87 ? thx

Maybe I should write a README or usage note 😅

But you can use hr helmrelease.yaml to render it, the other tools, like hrDiff should explain themselves 😁 You can also pipe into it There is tab completion And you can do hr hr.yaml $localHelmFolder to use a local version of the chart

cwrau avatar Mar 14 '24 17:03 cwrau

It is also possible to use process substitution <(cmd), which treats the output of a command as a file to filter out the .spec.values from the HelmRelease to use it in helm template:

helm template <releasename> <helmrepo>/<helmchart> --values <(yq .spec.values < release.yaml) > manifests.yaml

wernerwws avatar May 09 '24 09:05 wernerwws