#helmfile (2023-09)

https://github.com/helmfile/helmfile

Questions and discussion around helmfile https://github.com/roboll/helmfile and https://github.com/cloudposse/helmfiles

Archive: https://archive.sweetops.com/helmfile/

2023-09-06

jz avatar

Hi, I have trouble getting values from environment to my chart. Did I miss something ? (Helm 3.12.3, Helmfile 0.156.0)

/helmfile.yaml

...
environments:
  staging:
    values:
      - fromEnv: HelloFromEnv
releases:
- name: ...
  ...
  values:
    ...
    - fromRelease: HelloFromRelease

/charts/myChart/templates/deployment.yaml

...
testFromRelease: {{ .Values.fromRelease }}
testFromEnv: {{ .Values.fromEnv }}

Command helmfile template -e staging results in:

testFromEnv: null
testFromRelease: HelloFromRelease
voron avatar

Helmfile’s environment values affect helmfile-only state. It’s not passed to helm releases as helm values. You may use

releases:
- name: ...
  ...
  values:
    ...
    - fromRelease: HelloFromRelease
    - fromEnv: {{ $.StateValues.fromEnv }}

to pass fromEnv as a helm value

jz avatar

Ok, thank you, it works perfectly.

1

2023-09-07

Phil Chen avatar
Phil Chen

I’m struggling with a simple helmfile where I would like control which release should be installed in a given env. Here is the exmaple helmfile.yaml file:

environments: dev: values: - dev.env.yaml staging: values: - staging.env.yaml prod: values: - prod.env.yaml — repositories:

releases:

  • name: kube-prometheus-stakc namespace: prometheus chart: prometheus-community/{{{{ .Release.Name }} }} version: 30.3.1 installed: {{ .Values.prometheus.enabled }}
Prometheus Community Kubernetes Helm Charts

Prometheus community Helm charts

Phil Chen avatar
Phil Chen

In addition, I have env specific values file. For example: dev.env.yaml like this:

prometheus: enabled: True

Phil Chen avatar
Phil Chen

When run this command:

helmfile template -e dev

I got this error: in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index `: yaml: invalid map key: map[interface {}]interface {}[“.Values.prometheus.enabled”:interfac {}<nil>}

Phil Chen avatar
Phil Chen

This works but it is a little ugly:

{{ if .Values.prometheus.enabled }}
installed: true
{{ else }}
installed: false
{{ end }}
yxxhero avatar
yxxhero

try to replace True into true.

Phil Chen avatar
Phil Chen

Thanks @yxxhero. that seems to solve the problem!!!

Phil Chen avatar
Phil Chen

I tried change this line to this but it does work either:

installed: {{ ``{ .Values.prometheus.enabled }} }}

Phil Chen avatar
Phil Chen

What am I missing? Thanks in advance for help tips.

yxxhero avatar
yxxhero

use true .

2023-09-08

Phil Chen avatar
Phil Chen

I have multiple clusters. Not all of them will have the same charts installed. To be DRY, I created a common helmfile which contains common charts that I would like to install for all clusters. IWhat is the recommended best practice for combining this common helmfile with the cluster specific helmfile?

Phil Chen avatar
Phil Chen

I try to follow the example here:

Phil Chen avatar
Phil Chen

It doesn’t seem to work.

Phil Chen avatar
Phil Chen

First the observability/helmfile.yaml is wrong on the example as it doesn’t have valid top level config key.

Phil Chen avatar
Phil Chen

Add the top level key “releases:” solved the issue, but it complains about .Values missing some keys. It looks like the helmfile try to render the templates defined in the sub helmfile.

yxxhero avatar
yxxhero

@Phil Chen please share your demo in github.

Phil Chen avatar
Phil Chen
Phil Chen avatar
Phil Chen

@yxxhero attached is my tests helmfile directory structure.

Phil Chen avatar
Phil Chen

After you untar the tarball. cd helmfile/team/teamA helmfile lint -e dev

you will see the error.

Phil Chen avatar
Phil Chen

I looks like the Environment values are not passed to the sub-helmfiles

Phil Chen avatar
Phil Chen

Looks like it worked if I rename the “common.yaml” to “common.yaml.gotmpl”

Phil Chen avatar
Phil Chen

It works on heimfile version 0.149, but not for the verision 0.156, a regress?

yxxhero avatar
yxxhero

which part is not work in 0.156?

yxxhero avatar
yxxhero

@Phil Chen

Phil Chen avatar
Phil Chen

With 0.156, I had issue with complain about sub-helmfile missing top level config. If I add the top level config “releases: “, the complain went away, but it doesn’t render the template even with “.gottmpl” at the end of “common.yaml.gotmp”. With 0.149, it seems working okay.

yxxhero avatar
yxxhero

any logs?

Phil Chen avatar
Phil Chen

I take it back @yxxhero The 0.149 doesn’t work either. I had a typo in the gotmpl. It didn’t find the file and skipped. Hence it didn’t show error. I find out by example the resulted template results and verified that with debug enabled. Now, we are back to the square one: the shared common sub helmefile doesn’t work if it contains template as the environment .Values not passed in to the sub helmfile. The example shared helmfile in the documentation doesn’t use template, so that works fine.

Phil Chen avatar
Phil Chen

Here is my example:

  • name: kube-promethues-stack namespace: prometheus chart: premetheus-community/{{{{ .Release.Name}}}} version: 45.7.1 installed: {{ .Values.prometheus.enabled }} inherit:
    • template: default
Phil Chen avatar
Phil Chen

As you can see it references {{ .Values.prometheus.enabled }} from Envrionment values.

Phil Chen avatar
Phil Chen

The {{{{ .Release.Name }} }} is okay though

Phil Chen avatar
Phil Chen

I guess the questions is there any way we can pass Environment values from the parent helmfile to the child helmfile?

2023-09-10

Phil Chen avatar
Phil Chen

I have a few simple k8s manifest files and what is the simplist way to deploy them with helmfile?

Phil Chen avatar
Phil Chen

Those k8s manifest is not s simple yaml file. They contains go templates just like a helm chart templates. I can see one way to do this is to create a helm chart, but reading document, the helmfile might be able to chartify them automatically.

Phil Chen avatar
Phil Chen

I used helmify to create a local helm chart for the extras manifests–I wish there an easier and better way to do this. But anyway, after I created the chart in local directory: charts/my_manifest_local_chart, I added this to the helmfile

releases:

Phil Chen avatar
Phil Chen

releases:

  • name: my_app <<: *default namespace: my_ns chart: chart/my_manifest_local_chart
Phil Chen avatar
Phil Chen

But I am getting this error:

ARGS: 0: helm (4 bytes) 1: fetch (5 bytes) 2: charts/my_manifest_local_chart 3: –untar 4: –untardir 5: /tmp/helmfilexxxx…./charts/my_manifest_local_chart/lastest

ERROR: exit status 1

EXIT STATUS 1

STDERR: Error: repo charts not found

Phil Chen avatar
Phil Chen

Why it try to fetch a local chart?

yxxhero avatar
yxxhero

if it is a lcoal chart. please use the format like “./”.

Phil Chen avatar
Phil Chen

Thanks @yxxhero that worked.

Phil Chen avatar
Phil Chen

Now, I am trying with a directory that contains yaml files. my understanding is that helmfile will chartify it. Are yaml files allowed to have go templates? The answer might be not? Then I guess is if that is not support, any possibility to add it?

Phil Chen avatar
Phil Chen

People who like kustomize are those who doesn’t like template. people who like helmfile are those who are appreciate the power of templates it bring on table.

helm and kustimize represents 2 approaches for customize the k8s manifest for different deployment requirements. while kustomize is simpler to learn and easier to get started, helm brings in sharable package and releases concept which kustomize doesn’t have.

By supporting create a release from regular k8s manifest files and kustomize, helmfile bring the benefit of helm to the kustomize and ad-hoc k8s manifests.

Now, if we add options to allow template k8s manifest and kustomize, we would give use a very powerful tool to further blur the line btw the template and non template overlay approach, bridge the gap. For example, instead of writing a overlay for each env, we can write an overlay that contains simple go template and rendered by helmfile before it applies the overlay and creates the temporary helm chart.

1
Phil Chen avatar
Phil Chen

@yxxhero do you think it makes sense to extend the helmfile to allow combine template and the kustomize?

yxxhero avatar
yxxhero

@Phil Chen you can post a discussion in github.

Phil Chen avatar
Phil Chen

Okay, will do. Thanks for the suggestion and much appreciated for your help!

Phil Chen avatar
Phil Chen
#1023 k8s manifest file and kustomize file template

It is great for helmfile to be able to deploy k8s manifest files and kustomization in addition to helm charts. I’d like to see we bring the power of helmfile templating to the manifest files and kustomization. In other words, to have helmfile render the manifest files file and kustomization based on environment values. This will be a powerful extension to add the power templating to kustomization and manifest.

One example usage is that instead of writing one overlay for each env, we might be able to write only a single templated overlay with go templates embedded. This could be significantly DRY.

2023-09-11

2023-09-12

2023-09-13

Sean avatar

FYI: helmfile now supports symlinks: https://github.com/helmfile/helmfile/pull/1020

#1020 Fix symlink behaviour

Make sure to evaluate symlinks when the path is not absolute and not
local. Otherwise just fall back to regular absolute paths.

Fixes #1013

5
    keyboard_arrow_up