I would like to be able to reference the current namespace in values.yaml
to use it to suffix some values like this
# in values.yaml
someParam: someval-{{ .Release.Namespace }}
It much nicer to define it this way instead of going into all my templates and adding {{ .Release.Namespace }}
. If I can do it in values.yaml
it's much clearer and only needs to be defined in one place.
Chart developers may supply a file called values. yaml inside of a chart. This file can contain default values. Chart users may supply a YAML file that contains values.
Release. Namespace : The namespace to be released into (if the manifest doesn't override) Release. IsUpgrade : This is set to true if the current operation is an upgrade or rollback.
The list above is in order of specificity: values. yaml is the default, which can be overridden by a parent chart's values. yaml , which can in turn be overridden by a user-supplied values file, which can in turn be overridden by --set parameters. Values files are plain YAML files. Let's edit mychart/values.
You can use named templates to define re-usable helper templates. E.g.
In templates/_helpers.tpl
:
{{- define "myChart.someParam" -}}someval-{{ .Release.Namespace }}{{- end -}}
In templates/configmap.yaml
(for example):
apiVersion: v1
kind: ConfigMap
metadata:
name: something
data:
foo: {{ template "myChart.someParam" . }}
The result:
$ helm template . --namespace=bar
---
# Source: helm/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: something
data:
foo: someval-bar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With