I would like to template values in my Chart.yaml file.
For example, version: {{ .Values.version }}
instead of version: 0.1.0
For other yaml files, the above would work. However, it's my understanding that Helm treats the Chart.yaml differently and the Chart.yaml file is not run through the templating engine.
Does anyone know a workaround?
The actual error I get if I try to helm lint this (with version: 0.1.0
as an entry in my values.yaml file) is:
error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{".Values.version":interface {}(nil)}
You are thinking of the problem backward: specify the version in Chart.yaml
and derive the version in wherever you are using it in the templates; you can't have a dynamic version in the Chart.yaml
because helm repo index .
does not accept --set
or any such flag and thus couldn't construct the tgz to upload
Thus, given a Chart.yaml
:
apiVersion: v1
name: my-awesome-chart
appVersion: 0.1.0
version: 1.2.3
and a Deployment.yaml
template:
{{ $myTag := .Chart.Version }}
{{/* or, you can use .Chart.AppVersion */}}
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
containers:
- image: docker.example.com:{{ $myTag }}
# produces: docker.example.com:1.2.3
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