function "env" not defined

1/10/2018

I'm pretty new to helm and go templates so please bear with me

I have a template called secrets.yaml:

apiVersion: v1
kind: Secret
metadata:
  name: fooo-secrets
  labels:
    app: {{ template "fooo.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
type: Opaque # TODO
data:
  SUPER_SECRET: {{env SUPER_SECRET | quote }} <--- the problem line

I got env from sprig. The idea is that I can load up my secrets into my local environment and then deploy from there.

But when I lint my chart:

> helm lint fooo                                                   [13:29]
==> Linting fooo
[INFO] Chart.yaml: icon is recommended
[ERROR] templates/: parse error in "drone_ci/templates/secrets.yaml": template: drone_ci/templates/secrets.yaml:12: function "env" not defined

What am I doing wrong here?

-- Sheena
kubernetes
kubernetes-helm
templates

1 Answer

1/10/2018

to pass this to a helm chart you should use values.

Instead of {{env SUPER_SECRET | quote }} use {{ .Values.secret }} and then when you run helm run it as for example helm install chart --set secret=${SUPER_SECRET}

-- Radek 'Goblin' Pieczonka
Source: StackOverflow