#helmfile - March 2022

KimJohn Quinn
KimJohn Quinnover 4 years ago
I am really wrestling with helmfile in application. I think i understand what I can do but the values are killing me.

Using Redis chart as an example:

I have a hemlfile.yaml
bases:
  - ../common.yml
  - environments.yml
---
repositories:
  - name: bitnami
    url: <https://charts.bitnami.com/bitnami>

releases:
  - name: redis
    chart: bitnami/redis
    force: true
    installed: {{ env "REDIS_INSTALLED" | default .Values.installed }}
    version: 16.4.5
    labels:
      managed: true
    values:
      - values.gotmpl

My environments.yml looks like (truncated):
environments:
  default:
    values:
      - ../globals.gotmpl
      - defaults.yml
  develop:
    values:
      - ../globals.gotmpl
      - defaults.yml

And my defaults.yml looks like (i have a production one as well):
installed: true

architecture: standalone
  
master:
  persistence:
    enabled: false

replica:
  persistence:
    enabled: false
  replicaCount: 0

My issues are:
1. It seems I have to "replicate" the properties inside the values.gotmpl when I would of expected them to be inherited from globals.yml
2. Just within the Redis chart itself I seem to have to do # 1 as well - even if i get rid of the values.gotmpl I would of expected it to use one of the environment files
My values.gotmpl looks like this:
architecture: {{ .Values.architecture }}

master:
  persistence:
    enabled: {{ .Values.master.persistence.enabled }}
  
replica:
  persistence:
    enabled: {{ .Values.replica.persistence.enabled }}
  replicaCount: {{ .Values.replica.replicaCount }}

And all it is doing is repeating the values from the environment files.
KimJohn Quinn
KimJohn Quinnover 4 years ago
The reason I am asking here is because it seems like you are heavy users of Helmfile and honestly the only real resource I seem to be able to locate.
Johan
Johanover 4 years ago
Does anyone know how to ensure a release is not installed when a flag is set? condition: mychart.disabled ?
Loukas Agorgianitis
Loukas Agorgianitisover 4 years ago(edited)
Hello! In my helmfile.yaml I have this:
values:
  - .env.yaml

in order to source all top level {{ .Values }}.
Can I somehow make this conditional and check first if the values are defined from --values (or environment variables) and then fall back to this?
brandon
brandonover 4 years ago
Hello. I have a question about the tpl function. Is it possible to have locally defined variables be used within a templated textfile?

# alerting.yaml.gotmpl

{{- $deadMansSwitchEndpoint := printf "myString" }}
receivers:
{{ tpl ( readFile "../prom-rules/alertmanager/alertmanager-receivers.yaml") . }}

Where
# ../prom-rules/alertmanager/alertmanager-receivers.yaml
- name: deadmanswitch
  webhook_configs:
  - url: {{ $deadMansSwitchEndpoint }}
    send_resolved: false

helmfile --file alerting.yaml template

failed to render values files "alerting.yaml.gotmpl": failed to render [alerting.yaml.gotmpl], because of template: stringTemplate:70:3: executing "stringTemplate" at <tpl (readFile "../prom-rules/alertmanager/alertmanager-receivers.yaml") .>: error calling tpl: template: stringTemplate:4: undefined variable "$deadMansSwitchEndpoint"

The only example I see in the docs does not use the $variable syntax. And even then this example is for base helm, and not helmfile.
https://helm.sh/docs/howto/charts_tips_and_tricks/
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)over 4 years ago