From 245ef7479bf2ef360b0dd264c9df9770a3415550 Mon Sep 17 00:00:00 2001
From: Andri Joos <andri@joos.io>
Date: Mon, 3 Feb 2025 15:11:43 +0100
Subject: [PATCH] add traefik tls store template

---
 common/templates/_helpers.tpl          | 10 ++++++++++
 common/templates/traefik/_tlsstore.tpl | 21 +++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 common/templates/traefik/_tlsstore.tpl

diff --git a/common/templates/_helpers.tpl b/common/templates/_helpers.tpl
index 14a6fed..8ae0f2f 100644
--- a/common/templates/_helpers.tpl
+++ b/common/templates/_helpers.tpl
@@ -102,3 +102,13 @@ IngressRoute
 {{- end }}
 {{- toYaml $routes -}}
 {{- end }}
+
+{{/*
+TLSStore
+*/}}
+
+{{- define "common.traefik.variables.tlsstore.certificates" -}}
+{{- range $secretName := .Values.certificates -}}
+- secretName: {{ $secretName }}
+{{- end }}
+{{- end }}
diff --git a/common/templates/traefik/_tlsstore.tpl b/common/templates/traefik/_tlsstore.tpl
new file mode 100644
index 0000000..e72dec0
--- /dev/null
+++ b/common/templates/traefik/_tlsstore.tpl
@@ -0,0 +1,21 @@
+# https://github.com/traefik/traefik/blob/master/docs/content/routing/providers/kubernetes-crd.md#kind-tlsstore
+{{- define "common.traefik.tlsstore" }}
+apiVersion:  {{ .Values.apiVersion | default "traefik.io/v1alpha1" }}
+kind: TLSStore
+metadata:
+  name: {{ .Values.name | default "tlsstore" }}
+  {{- with .Values.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+  labels:
+    {{- include "common.variables.labels" . | nindent 4 }}
+spec:
+  {{- with .Values.defaultCertificateSecretName }}
+  defaultCertificate:
+    secretName: {{ toYaml . }}
+  {{- end }}
+  certificates:
+    {{- include "common.traefik.variables.tlsstore.certificates" . | nindent 4 }}
+---
+{{- end }}
-- 
GitLab