Using unique names for TLS secrets

This commit is contained in:
Laszlo Fogas
2021-08-13 09:10:47 +02:00
parent 324617b0de
commit 269ab7e376
5 changed files with 26 additions and 6 deletions
Binary file not shown.
Binary file not shown.
+6 -6
View File
@@ -1,15 +1,15 @@
{{/* OneChart ingress snippet */}}
{{- define "onechart.ingress" }}
{{- $robustName := include "robustName" .root.Release.Name -}}
{{- $resourceName := $robustName -}}
{{- if .longName }}
{{- $resourceName = printf "%s-%s" $robustName (include "robustName" .ingress.host) -}}
{{- end }}
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
{{- if .longName }}
name: {{ $robustName }}-{{ template "robustName" .ingress.host }}
{{- else }}
name: {{ $robustName }}
{{- end }}
name: {{ $resourceName }}
namespace: {{ .root.Release.Namespace }}
labels:
{{- include "helm-chart.labels" .root | nindent 4 }}
@@ -30,7 +30,7 @@ spec:
tls:
- hosts:
- {{ template "robustName" .ingress.host | quote }}
secretName: {{ printf "tls-%s" $robustName }}
secretName: {{ printf "tls-%s" $resourceName }}
{{- end }}
rules:
- host: {{ template "robustName" .ingress.host | quote }}
@@ -83,3 +83,21 @@ tests:
asserts:
- hasDocuments:
count: 3
- it: Should have unique TLS secret names
set:
ingresses:
- host: chart-example.local
tlsEnabled: true
annotations:
kubernetes.io/ingress.class: nginx
- host: another.local
tlsEnabled: true
annotations:
kubernetes.io/ingress.class: nginx
asserts:
- equal:
path: spec.tls
value:
- hosts:
- chart-example.local
secretName: tls-release-name-chart-example.local
+2
View File
@@ -4,9 +4,11 @@ ingress:
kubernetes.io/ingress.class: nginx
ingresses:
- host: chart-example.local
tlsEnabled: true
annotations:
kubernetes.io/ingress.class: nginx
- host: another.local
tlsEnabled: true
annotations:
kubernetes.io/ingress.class: nginx