Helm – Creating Secret from Variable

 

In order to save the value of the variable as Secret, the variable must be encoded in base64, for this we use “_helpers.tpl

For example, we need to save the value of the variable “applicationSecret

values.yaml:

# Default values for artem-services.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
namespace: default

image:
  repository: XXXXXXXXXXXX.dkr.ecr.eu-east-1.amazonaws.com/artem-services
  tag: 1.0.1
  pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: "artem-services"

applicationSecret: |
  var1=value1
  var2=value2
  var3=value3
  var4=value4

 

Add the following to “_helpers.tpl“:

_helpers.tpl:

{{- define "applicationSecret" }}
{{- printf .Values.applicationSecret | b64enc }}
{{- end }}

 

Now in the “templates” directory, create the file “secret.yaml

secret.yaml:

apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: "{{ .Chart.Name }}-application"
data:
  application.conf: {{ template "applicationSecret" . }}

Tagged: Tags

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments