Using unique names for TLS secrets
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,15 +1,15 @@
|
|||||||
{{/* OneChart ingress snippet */}}
|
{{/* OneChart ingress snippet */}}
|
||||||
{{- define "onechart.ingress" }}
|
{{- define "onechart.ingress" }}
|
||||||
{{- $robustName := include "robustName" .root.Release.Name -}}
|
{{- $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
|
apiVersion: networking.k8s.io/v1beta1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
{{- if .longName }}
|
name: {{ $resourceName }}
|
||||||
name: {{ $robustName }}-{{ template "robustName" .ingress.host }}
|
|
||||||
{{- else }}
|
|
||||||
name: {{ $robustName }}
|
|
||||||
{{- end }}
|
|
||||||
namespace: {{ .root.Release.Namespace }}
|
namespace: {{ .root.Release.Namespace }}
|
||||||
labels:
|
labels:
|
||||||
{{- include "helm-chart.labels" .root | nindent 4 }}
|
{{- include "helm-chart.labels" .root | nindent 4 }}
|
||||||
@@ -30,7 +30,7 @@ spec:
|
|||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- {{ template "robustName" .ingress.host | quote }}
|
- {{ template "robustName" .ingress.host | quote }}
|
||||||
secretName: {{ printf "tls-%s" $robustName }}
|
secretName: {{ printf "tls-%s" $resourceName }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
rules:
|
rules:
|
||||||
- host: {{ template "robustName" .ingress.host | quote }}
|
- host: {{ template "robustName" .ingress.host | quote }}
|
||||||
|
|||||||
@@ -83,3 +83,21 @@ tests:
|
|||||||
asserts:
|
asserts:
|
||||||
- hasDocuments:
|
- hasDocuments:
|
||||||
count: 3
|
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
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ ingress:
|
|||||||
kubernetes.io/ingress.class: nginx
|
kubernetes.io/ingress.class: nginx
|
||||||
ingresses:
|
ingresses:
|
||||||
- host: chart-example.local
|
- host: chart-example.local
|
||||||
|
tlsEnabled: true
|
||||||
annotations:
|
annotations:
|
||||||
kubernetes.io/ingress.class: nginx
|
kubernetes.io/ingress.class: nginx
|
||||||
- host: another.local
|
- host: another.local
|
||||||
|
tlsEnabled: true
|
||||||
annotations:
|
annotations:
|
||||||
kubernetes.io/ingress.class: nginx
|
kubernetes.io/ingress.class: nginx
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user