Skip to content

Commit

Permalink
Using unique names for TLS secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Aug 13, 2021
1 parent 324617b commit 269ab7e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
Binary file modified charts/cron-job/charts/common-0.1.0.tgz
Binary file not shown.
Binary file modified charts/onechart/charts/common-0.1.0.tgz
Binary file not shown.
12 changes: 6 additions & 6 deletions charts/onechart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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 }}
Expand Down
18 changes: 18 additions & 0 deletions charts/onechart/tests/ingress_domain_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 269ab7e

Please sign in to comment.