Interview Prep/Helm/Templating: Go Templates & Sprig

How do you base64-encode values for a Secret, and when should you use `stringData`?

BeginnerConceptTemplating: Go Templates & Sprig
Answer
apiVersion: v1
kind: Secret
type: Opaque
data:
  password: {{ .Values.db.password | b64enc | quote }}
# or
stringData:
  password: {{ .Values.db.password | quote }}

stringData is simpler and avoids double encoding mistakes; the API server converts it to data. Either way, the plain value is stored in the Helm release Secret (merged values), so anyone who can read Secrets in the namespace can read it. Base64 is encoding, not encryption.

All Helm questions Roadmap: Helm

More on Templating: Go Templates & Sprig