Helmfile: Install a directory of K8s manifests as a chart does not work

Created on 13 Aug 2020  ยท  12Comments  ยท  Source: roboll/helmfile

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?

bug

Most helpful comment

@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

All 12 comments

@pandvan Thank you so much for reporting!

This was indeed a regression since 0.125.6 and I'm fixing it shortly via https://github.com/variantdev/chartify/commit/dba403c8f0b35cff2695afecb5d26e12984a6307 and #1417.

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.

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

@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 | :heavy_check_mark: | |
| 0.121.0 | :heavy_check_mark: | |
| 0.122.0 | :heavy_check_mark: | |
| 0.123.0 | :x: | 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 | :x: | 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 | :x: | 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 | :x: | ... [invalid state: no files rendered] |
| 0.127.0 | :x: | ... [invalid state: no files rendered] |
| 0.137.0 | :x: | ... [invalid state: no files rendered] |
| 0.138.7 | :x: | ... [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.

@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?

Also, could you confirm that you did specify chart: ./chart/templates for https://github.com/roboll/helmfile/issues/1413#issuecomment-764570482 ? 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.

@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 https://github.com/roboll/helmfile/issues/1413#issuecomment-818599061.

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 https://github.com/roboll/helmfile/issues/1413#issuecomment-764570482 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

@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?

@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 https://github.com/roboll/helmfile/issues/1413#issuecomment-818599061.


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 https://github.com/roboll/helmfile/issues/1413#issuecomment-764570482:

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.

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.

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:

@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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mumoshu picture mumoshu  ยท  4Comments

aslafy-z picture aslafy-z  ยท  4Comments

ppawiggers picture ppawiggers  ยท  3Comments

madAndroid picture madAndroid  ยท  3Comments

RafalMaleska picture RafalMaleska  ยท  3Comments