Reputation: 1386
I have a custom helm chart that I wrote which has a deployment.yaml
, service.yaml
and other yamls. Now, I want to included a sealed-secret.yaml template file such as following in it:
{{- if .Values.sealedSecrets -}}
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
creationTimestamp: null
name: {{ include "mychart.fullname" . }}-sealedsecret
namespace: {{ .Release.Namespace }}
labels:
{{- include "mychart.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install
spec:
encryptedData:
{{- range .Values.sealedSecrets }}
{{ .key }}: {{ .value }}
{{- end }}
template:
data: null
metadata:
creationTimestamp: null
name: {{ include "mychart.fullname" . }}-sealedsecret
namespace: {{ .Release.Namespace }}
{{- end }}
However, when I install my app using the Helm chart I don't see the secret being generated. I also checked the Helm manifest for the deployed app and I don't see the sealed-secret.yaml file in it.
Do I need to do something special for a sealed secret?
Upvotes: 0
Views: 641
Reputation: 1
I hope this example helps to you :) @Katlock
$ cd /tmp
$ helm create mychart
$ find mychart/
mychart/
mychart/charts
mychart/templates
mychart/templates/tests
mychart/templates/tests/test-connection.yaml
mychart/templates/_helpers.tpl
mychart/templates/NOTES.txt
mychart/templates/hpa.yaml
mychart/templates/serviceaccount.yaml
mychart/templates/service.yaml
mychart/templates/deployment.yaml
mychart/templates/ingress.yaml
mychart/.helmignore
mychart/values.yaml
mychart/Chart.yaml
$ rm -rf mychart/templates/test
$ rm -f mychart/templates/*.yaml
$ cat <<EOF > mychart/templates/sealedsecret.yaml
> {{- if .Values.sealedSecrets -}}
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
creationTimestamp: null
name: {{ include "mychart.fullname" . }}-sealedsecret
namespace: {{ .Release.Namespace }}
labels:
{{- include "mychart.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install
spec:
encryptedData:
{{- range .Values.sealedSecrets }}
{{ .key }}: {{ .value }}
{{- end }}
template:
data: null
metadata:
creationTimestamp: null
name: {{ include "mychart.fullname" . }}-sealedsecret
namespace: {{ .Release.Namespace }}
{{- end }}
EOF
$ cat <<EOF > values.yaml
> sealedSecrets:
- key: my_key
value: my_value
- key: my_second_key
value: my_second_value
EOF
$ find mychart/
mychart/
mychart/charts
mychart/templates
mychart/templates/sealedsecret.yaml
mychart/templates/NOTES.txt
mychart/templates/_helpers.tpl
mychart/.helmignore
mychart/values.yaml
mychart/Chart.yaml
helm template my-chart mychart/ -f values.yaml
---
# Source: mychart/templates/sealedsecret.yaml
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
creationTimestamp: null
name: my-chart-mychart-sealedsecret
namespace: my-namespace
labels:
helm.sh/chart: mychart-0.1.0
app.kubernetes.io/name: mychart
app.kubernetes.io/instance: my-chart
app.kubernetes.io/version: "1.16.0"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": pre-install
spec:
encryptedData:
my_key: my_value
my_second_key: my_second_value
template:
data: null
metadata:
creationTimestamp: null
name: my-chart-mychart-sealedsecret
namespace: my-namespace
Upvotes: 0