#helmfile (2023-09)
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
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
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
2023-09-07
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:
- name: prometheus-community url: https://prometheus-community.github.io/helm-charts
releases:
- name: kube-prometheus-stakc
namespace: prometheus
chart: prometheus-community/{{
{{ .Release.Name }}
}} version: 30.3.1 installed: {{ .Values.prometheus.enabled }}
Prometheus community Helm charts
In addition, I have env specific values file. For example: dev.env.yaml like this:
prometheus: enabled: True
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>}
This works but it is a little ugly:
{{ if .Values.prometheus.enabled }}
installed: true
{{ else }}
installed: false
{{ end }}
try to replace True into true.
Thanks @yxxhero. that seems to solve the problem!!!
I tried change this line to this but it does work either:
installed: {{ ``{ .Values.prometheus.enabled }}
}}
What am I missing? Thanks in advance for help tips.
use true
.
2023-09-08
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?
I try to follow the example here:
It doesn’t seem to work.
First the observability/helmfile.yaml is wrong on the example as it doesn’t have valid top level config key.
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.
@Phil Chen please share your demo in github.
@yxxhero attached is my tests helmfile directory structure.
After you untar the tarball. cd helmfile/team/teamA helmfile lint -e dev
you will see the error.
I looks like the Environment values are not passed to the sub-helmfiles
Looks like it worked if I rename the “common.yaml” to “common.yaml.gotmpl”
It works on heimfile version 0.149, but not for the verision 0.156, a regress?
which part is not work in 0.156?
@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.
any logs?
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.
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
As you can see it references {{ .Values.prometheus.enabled }} from Envrionment values.
The {{{{ .Release.Name }}
}} is okay though
I guess the questions is there any way we can pass Environment values from the parent helmfile to the child helmfile?
2023-09-10
I have a few simple k8s manifest files and what is the simplist way to deploy them with helmfile?
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.
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:
releases:
- name: my_app <<: *default namespace: my_ns chart: chart/my_manifest_local_chart
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
Why it try to fetch a local chart?
if it is a lcoal chart. please use the format like “./”.
Thanks @yxxhero that worked.
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?
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.
@yxxhero do you think it makes sense to extend the helmfile to allow combine template and the kustomize?
@Phil Chen you can post a discussion in github.
Okay, will do. Thanks for the suggestion and much appreciated for your help!
@yxxhero here is the discussion: https://github.com/helmfile/helmfile/discussions/1023
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
FYI: helmfile
now supports symlinks: https://github.com/helmfile/helmfile/pull/1020
Make sure to evaluate symlinks when the path is not absolute and not
local. Otherwise just fall back to regular absolute paths.
Fixes #1013