Nahum
Nahum

Reputation: 7197

generate release name from values

I got a helm template that generates a deployment I need a separate deployment for each combination of 3 values the chart gets as parameters

helm upgrade -i release_name folder --set a=x --set b=y --set c=z

So i need release name to be a template based on a,b,c {.Values.a},{.Values.b}{.Values.c}

Is there any way to do something like this? the best way I found so far is an external python script that generates the release name and passes the parameters.

I know I can do the other way around and split the

$parts := split "." .Release.Name
$parts._0

and use it as params but I would really like to avoid it.

Upvotes: 0

Views: 1664

Answers (1)

Emruz Hossain
Emruz Hossain

Reputation: 5558

You can use Helm Named Template to define a function that generate the release name for the desired values. Then, you can use that template function in your resource YAML.

For example, lets define a function in _helpers.tpl file.

{{- define "release.name" -}}
{{- list .Values.a .Values.b .Values.c | join "-" }}
{{- end }}

Now, use this template function as your release name in your resource YAML file. For example,

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: {{ include "release.name" . }}
  labels:
    app: {{ .Release.Name }}
    chart: ni-filecleaner
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}

Upvotes: 1

Related Questions