Skip to content
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

Install a directory of K8s manifests as a chart does not work #1413

Closed
pandvan opened this issue Aug 13, 2020 · 12 comments · Fixed by #1417
Closed

Install a directory of K8s manifests as a chart does not work #1413

pandvan opened this issue Aug 13, 2020 · 12 comments · Fixed by #1417
Labels

Comments

@pandvan
Copy link

pandvan commented Aug 13, 2020

I am trying to install a directory of K8s manifests as a chart as described in #1172 with the latest Helmfile v0.125.6 but it does not work properly.
Minimizing the example as much as possible, with a simply

releases:
  - name: prometheus-stack-addons
    chart: ../prometheus-stack-addons

and a single .yaml file inside the "chart" directory, helmfile template produces the following error

using the default chart version 1.0.0 due to that no ChartVersion is specified
using requirements.yaml:
{}

running helm dependency up /tmp/chartify057788044
options: {false [] []   true}
running helm template --debug=false --include-crds --output-dir /tmp/chartify057788044/helmx.1.rendered prometheus-stack-addons /tmp/chartify057788044
in ./helmfile.yaml: [invalid state: no files rendered]

Using the previous v0.125.5 the same release is properly rendered.
Could be a possible regression? Or this feature is inteded to be used in a different way?

@mumoshu
Copy link
Collaborator

mumoshu commented Aug 14, 2020

@pandvan Thank you so much for reporting!

This was indeed a regression since 0.125.6 and I'm fixing it shortly via helmfile/chartify@dba403c and #1417.

@vasrem
Copy link

vasrem commented Jan 21, 2021

Is this issue up again? I'm hitting this with 0.137.0.

if the chart is part of the folder where the helmfile is, then the issue occurs. If it's in a different folder, it doesn't.

Example:

├── chart
│   └── templates
│       └── some.yaml
└── helmfile.yaml

UPD: It turns out that the problem occurs if there is no Chart.yaml specified in the chart folder. Please ignore this.

UPD: It might actually be a bug. Maybe worth looking into it. From what I see in the code, there is a library used that can bootstrap a Chart.yaml file on the fly. https://github.com/variantdev/chartify/blob/master/chartify.go#L212-L235 so this should not really fail at this point.

@mumoshu
Copy link
Collaborator

mumoshu commented Jan 21, 2021

@vasrem Thanks for reporting. Just curious, but did the same configuration work for previous version(s) of helmfile?

@vasrem
Copy link

vasrem commented Apr 13, 2021

@mumoshu apologies from my side for the long delay.

Did some tests to find when the regression happened based on minor versions (didn't consider patches):

version works error
0.120.0 ✔️
0.121.0 ✔️
0.122.0 ✔️
0.123.0 Error: YAML parse error on XXX/helmx.all.yaml: error converting YAML to JSON: yaml: line 7: did not find expected node content
0.124.0 Error: YAML parse error on XXX/helmx.all.yaml: error converting YAML to JSON: yaml: line 7: did not find expected node content
0.125.0 Error: YAML parse error on XXX/helmx.all.yaml: error converting YAML to JSON: yaml: line 7: did not find expected node content
0.126.0 ... [invalid state: no files rendered]
0.127.0 ... [invalid state: no files rendered]
0.137.0 ... [invalid state: no files rendered]
0.138.7 ... [invalid state: no files rendered]

It seems that there is a change in the type of error between 0.125 and 0.126.

Let me know if there is something I could help with.

@mumoshu
Copy link
Collaborator

mumoshu commented Apr 13, 2021

@vasrem Hey! Thanks for the reply. I'm wondering if the content of your manifests is also contributing to the error. Would you mind sharing me your manifests (or a smaller subset of it) for reproduction if possible?

@mumoshu
Copy link
Collaborator

mumoshu commented Apr 13, 2021

Also, could you confirm that you did specify chart: ./chart/templates for #1413 (comment) ? chart: ./chart is not expected to work. But if it's that chart: ./chart worked before 0.123.0, I can investigate why that behaviour changed and investigate possibilities to bring that behaviour back and make it included in our test suite.

@vasrem
Copy link

vasrem commented Apr 13, 2021

@mumoshu

Also, could you confirm that you did specify chart: ./chart/templates for #1413 (comment) ?

I confirm that I specified this in all the tests I've done and the output of them can be found here #1413 (comment).

chart: ./chart is not expected to work. But if it's that chart: ./chart worked before 0.123.0, I can investigate why that behaviour changed and investigate possibilities to bring that behaviour back and make it included in our test suite.

That sounds great!

Would you mind sharing me your manifests (or a smaller subset of it) for reproduction if possible?

It's pretty simple to reproduce. Please use the structure mentioned above in #1413 (comment) with the following content.

some.yaml:

key: {{ .Values.myValue }}

helmfile.yaml:

releases:
- name: random-release 
  chart: ./chart
  values:
  - myValue: "randomValue"

By doing the following command, you can reproduce:

$ helmfile --file helmfile.yaml template

@mumoshu
Copy link
Collaborator

mumoshu commented Apr 14, 2021

@vasrem Hey! Thanks for confirmations and the additional info.

Your some.yaml does not look like a valid YAML so if you put that at ./chart/some.yaml and helmfile failed with the error, that's because of the invalid YAML.

Probably you had similar go template expression (that looks like {{ .... }} at line 7 in any of YAML files you've used originally? (I'm referring to line 7 as the error you've shared was Error: YAML parse error on XXX/helmx.all.yaml: error converting YAML to JSON: yaml: line 7: did not find expected node content, which says the yaml parser failed there)

Are you trying to render some YAML file as a Helmfile template and turning it into a temporary chart?

@vasrem
Copy link

vasrem commented Apr 14, 2021

@mumoshu

Your some.yaml does not look like a valid YAML so if you put that at ./chart/some.yaml and helmfile failed with the error, that's because of the invalid YAML.

This was failing between from v0.123.0 until v0.125.0. After that there is a different type of error. Please check table above #1413 (comment).


Are you trying to render some YAML file as a Helmfile template and turning it into a temporary chart?

The file some.yaml should indeed contain go template expressions since it's supposed to be a part of a Chart.

As I mentioned above #1413 (comment):

UPD: It turns out that the problem occurs if there is no Chart.yaml specified in the chart folder. Please ignore this.

if the chart doesn't contain a Chart.yaml file, helmfile template fails, while I see that there is code that is supposed to construct a Chart.yaml (didn't dig deep into that) and this behavior is not observed with earlier versions.

From what I see in the code, there is a library used that can bootstrap a Chart.yaml file on the fly. https://github.com/variantdev/chartify/blob/master/chartify.go#L212-L235 so this should not really fail at this point.

@mumoshu
Copy link
Collaborator

mumoshu commented Apr 14, 2021

The file some.yaml should indeed contain go template expressions since it's supposed to be a part of a Chart.

@vasrem Unfortunately, that's not how it's supposed to work today, at least. It must really be a directory containing only valid YAML files, or a local chart(with predefined Chart.yaml). For now, it's not a feature to create a valid chart from helm templates.

FWIW, coincidentally, you can start including gotmpl files rendered by Helmfile before turning it into a temporary helm chart, likesome.yaml.gotmpl, once #1745 gets released. Hope that helps.

if the chart doesn't contain a Chart.yaml file, helmfile template fails, while I see that there is code that is supposed to construct a Chart.yaml (didn't dig deep into that) and this behavior is not observed with earlier versions.

True. But at least I have never tested it for turning helm templates into a chart.

@vasrem
Copy link

vasrem commented May 6, 2021

FWIW, coincidentally, you can start including gotmpl files rendered by Helmfile before turning it into a temporary helm chart, likesome.yaml.gotmpl, once #1745 gets released. Hope that helps.

@mumoshu I gave this a try with the latest 0.139.0 release. Is there any documentation I can follow? I tried the following but the values are not rendered correctly:

├── some-folder
│   └── some.yaml.gotmpl
└── helmfile.yaml

Where the content of each file is:

some.yaml.gotmpl:

key: {{ .Values.myValue }}

helmfile.yaml:

releases:
- name: random-release 
  chart: ./some-folder
  values:
  - myValue: "randomValue"

The output of the command is (doesn't error out):

$ helmfile --file testdata/helmfile.yaml template
Building dependency release=random-release, chart=/tmp/chartify707654131/random-release
Templating release=random-release, chart=/tmp/chartify707654131/random-release
---
# Source: some-folder/templates/some.yaml
# Source: some-folder/templates/some.yaml
key:

@mumoshu
Copy link
Collaborator

mumoshu commented May 6, 2021

@vasrem As similar as values templates, only helmfile's environment and template context is available to .gotmpl.

So just don't use release values. Instead use environment values.

values:
- myValue: "randomValue"

releases:
- name: random-release 
  chart: ./some-folder

or

environments:
  default:
    values:
    - myValue: "randomValue"

releases:
- name: random-release 
  chart: ./some-folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants