Skip to content

Instantly share code, notes, and snippets.

@lodotek
Created June 6, 2023 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lodotek/88ae2b5b84fb2c5926172d6af7bffdd1 to your computer and use it in GitHub Desktop.
Save lodotek/88ae2b5b84fb2c5926172d6af7bffdd1 to your computer and use it in GitHub Desktop.
Helm Templated Sealed Secrets
{{- if and (.Values.sealedSecret) (.Capabilities.APIVersions.Has "bitnami.com/v1alpha1") }}
{{- range $nameSuffix, $config := .Values.sealedSecret.files }}
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
name: {{ template "application.name" $ }}-{{ $nameSuffix }}
namespace: {{ template "application.namespace" $ }}
labels:
{{- include "application.labels" $ | nindent 4 }}
{{- if $.Values.sealedSecret.additionalLabels }}
{{ toYaml $.Values.sealedSecret.additionalLabels | indent 4 }}
{{- end }}
{{- if $config.labels }}
{{ toYaml $config.labels | indent 4 }}
{{- end }}
{{- if or ($.Values.sealedSecret.annotations) ($config.annotations) ($config.clusterWide) }}
annotations:
{{- if $config.annotations }}
{{ toYaml $config.annotations | indent 4 }}
{{- end }}
{{- if $.Values.sealedSecret.annotations }}
{{ toYaml $.Values.sealedSecret.annotations | indent 4 }}
{{- end }}
{{- if $config.clusterWide}}
sealedsecrets.bitnami.com/cluster-wide: "true"
{{- end}}
{{- end }}
spec:
encryptedData:
{{- range $key, $value := $config.encryptedData }}
{{ $key }}: {{ $value }}
{{- end }}
template:
type: {{ $config.type | default "Opaque" }}
metadata:
name: {{ template "application.name" $ }}-{{ $nameSuffix }}
namespace: {{ template "application.namespace" $ }}
{{- if or ($.Values.sealedSecret.annotations) ($config.annotations) ($config.clusterWide) }}
annotations:
{{- if $config.annotations }}
{{ toYaml $config.annotations | indent 2 }}
{{- end }}
{{- if $.Values.sealedSecret.annotations }}
{{ toYaml $.Values.sealedSecret.annotations | indent 2 }}
{{- end }}
{{- if $config.clusterWide}}
sealedsecrets.bitnami.com/cluster-wide: "true"
{{- end}}
{{- end }}
{{- if or ($config.labels) ($.Values.sealedSecret.additionalLabels) }}
labels:
{{- if $config.labels }}
{{ toYaml $config.labels | indent 2 }}
{{- end }}
{{- if $.Values.sealedSecret.additionalLabels }}
{{ toYaml $.Values.sealedSecret.additionalLabels | indent 2 }}
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment