Skip to content

Multiple valuesFiles in HelmChart source #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arbourd opened this issue Feb 11, 2021 · 10 comments · Fixed by #305
Closed

Multiple valuesFiles in HelmChart source #291

arbourd opened this issue Feb 11, 2021 · 10 comments · Fixed by #305
Assignees
Labels
area/helm Helm related issues and pull requests good first issue Good for newcomers help wanted Extra attention is needed

Comments

@arbourd
Copy link
Contributor

arbourd commented Feb 11, 2021

Similar to the create HelmRelease command in Flux, it would be nice if the HelmRelease/HelmChart CRD could handle more than one values file from a single HelmChart that is sourced by a GitRepository. For example:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: example
  namespace: default
spec:
  releaseName: example
  chart:
    spec:
      chart: charts/example
      sourceRef:
        kind: GitRepository
        name: example-repo
        namespace: flux-system
      valuesFiles: 
        - charts/example/values.yaml              # one
        - charts/example/values-extend.yaml       # two
        - charts/example/values-production.yaml   # three
  interval: 5m
@hiddeco hiddeco transferred this issue from fluxcd/helm-controller Feb 11, 2021
@hiddeco hiddeco changed the title Multiple valuesFiles from GitRepository source Multiple valuesFiles in HelmChart source Feb 11, 2021
@hiddeco hiddeco added the area/helm Helm related issues and pull requests label Feb 11, 2021
@hiddeco
Copy link
Member

hiddeco commented Mar 3, 2021

Happy to accept a contribution that adds this feature.

To prevent and/or avoid backward compatibility issues, it would likely be best to add a new valuesFiles field that accepts a string array, and deprecate the valuesFile field (but it should still be taken into account, and if supplied, be used as a base for the merge of the valuesFiles).

https://github.com/fluxcd/pkg/blob/main/runtime/transform/transform.go#L24 helper is available for merging the values.

@hiddeco hiddeco added good first issue Good for newcomers help wanted Extra attention is needed labels Mar 3, 2021
@JLenssen
Copy link

JLenssen commented Mar 3, 2021

Would be happy to take this one

@arbourd
Copy link
Contributor Author

arbourd commented Mar 7, 2021

Hey @JLenssen what is the likelihood that you would be working on this soon? Our team actually has an extremely hacky version of this that mostly works in our staging environment (so we can try out Flux).

If this is something you might not be able to get to soon would you mind relinquishing it to us? If not please let me know if I can help! 😊

@hiddeco
Copy link
Member

hiddeco commented Mar 8, 2021

@arbourd if you have this pushed as a branch somewhere, feel free to open up a draft PR with it. I can then take a look at it to see what needs to happen to make it "less hacky", and @JLenssen or yourself can then make the adjustments :-).

@nniikkoollaaii
Copy link

We would also love to see this feature implemented as it prevents us from migrating to v2.

I don't have much experience with Go, but I would be happy to help.

@arbourd
Copy link
Contributor Author

arbourd commented Mar 29, 2021

Feel free to take a look at the PR at #305 @nniikkoollaaii. There are a few outstanding comments there you may be able to assist with. If not, I'm hoping to get back to it this weekend (just very busy with work-work) 😁

@mmingorance-dh
Copy link

mmingorance-dh commented Jun 22, 2021

@JLenssen @arbourd As per my understanding, those values files must be stored in the same place as the Helm Chart.
Would it be possible to allow this feature to take the values files from any other location? Example, cluster's directory.

The main reason for me would be to keep the different values files per cluster and not along with the Chart.

I for example would like to keep different values files in 3 different repositories (in the same repo as the cluster's directory is). The base directory would contain a default values.yaml file. Then I'd override those values per each environment (with a values.yaml file stored in an environment directory) and lastly, override with the values.yaml in the cluster's directory.

@hiddeco
Copy link
Member

hiddeco commented Jun 22, 2021

You can overwrite the cluster specific values using a ConfigMap or Secret which you refer to in the valuesFrom from the HelmRelease.

@mmingorance-dh
Copy link

@hiddeco that's a good advise, but what about the environment values? I'd also leave these per environment values in a different directory.

@mmingorance-dh
Copy link

I've been playing around with your solution @hiddeco and I ended up doing all this:

  1. I tried to create different CMs per directory (same name just different suffix):
    1. First, the default directory where the HelmRelease is defined with default values creates a "default values CM"
    2. Second, the environment directory where more values are being added. Creates a "environment values CM" - To be merged with the default values
    3. Third, the cluster directory where a couple of more values are particularly added to the cluster. Creates a "cluster values CM"

The final result of this attempt is that every time flux reconciles the structure (kustomize + helmrelease), a different CM will be picked up. And since it only takes 1 CM, values are always different, therefore the Chart is constantly changing the deployed resources + configurations.

  1. I tried to merge all the values into a single CM.
    1. First, the default directory creates a CM with the default values. This time it uses the behaviour: create when generating the CM.
    2. Second, the environment directory renders a new CM with the environment values and for this time, we use the behaviour: merge. Which in this case, would just completely override the CM with only the "environment values"
    3. Third, the cluster directory renders a new CM with the cluster values, and since this time we use the behaviour: merge again, it will once again, override the CM with only the cluster values.

I've been thinking on any other alternative and nothing pops up in my head. For me, the only way to move forward would be to allow the user to pass multiple values files to the argument valuesFiles but with the possibility to reference to different directories for each of them.
Considering that many applications are installed through public Helm Charts, I think using GitRepository to be able to store some custom values files along the Chart is "tedious" solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm Helm related issues and pull requests good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants