Skip to content

Commit

Permalink
Merge pull request #60 from WyriHaximusNet/redirect-have-an-ingress-p…
Browse files Browse the repository at this point in the history
…er-hostname

[redirect] Have an ingress per hostname
  • Loading branch information
WyriHaximus authored Feb 6, 2021
2 parents c2e19ac + 71a43ef commit d8d05f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
2 changes: 1 addition & 1 deletion charts/redirect/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Redirect
home: https://github.com/wyrihaximusnet/docker-redirect
icon: https://helm.wyrihaximus.net/images/charts/redirect.png
type: application
version: 0.9.4
version: 0.9.5
kubeVersion: ^1.18
appVersion: random
maintainers:
Expand Down
42 changes: 9 additions & 33 deletions charts/redirect/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
{{- $fullName := include "commons.fullname" . -}}
{{- $hosts := .Values.redirect.hosts -}}
{{- $ingressHosts := .Values.redirect.ingressHosts -}}
{{- $hosts := concat (.Values.redirect.ingressHosts | mustDeepCopy) (.Values.redirect.hosts | mustDeepCopy | keys) -}}
{{- range $host := ($hosts | uniq) }}
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
name: {{ $fullName }}-{{ $host | replace "." "-" }}
labels:
{{- include "commons.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
{{- include "commons.labels" $ | nindent 4 }}
{{- with $.Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
tls:
{{- if $hosts -}}
{{- range $hostFrom, $hostTo := $hosts }}
{{- $host := dict "Host" $hostFrom -}}
{{ include "redirect.hostTLS" $host | nindent 4 }}
{{- end }}
{{- end }}
{{- if $ingressHosts -}}
{{- range $host := $ingressHosts }}
{{- if eq (hasKey $hosts $host) false -}}
{{- $host := dict "Host" $host -}}
{{ include "redirect.hostTLS" $host | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{ include "redirect.hostTLS" (dict "Host" $host) | nindent 4 }}
rules:
{{- if $hosts -}}
{{- range $hostFrom, $hostTo := $hosts }}
{{- $host := dict "Host" $hostFrom "FullName" $fullName "SvcPort" 7132 -}}
{{ include "redirect.hostRule" $host | nindent 4 }}
{{- end }}
{{- end }}
{{- if $ingressHosts -}}
{{- range $host := $ingressHosts }}
{{- if eq (hasKey $hosts $host) false -}}
{{- $host := dict "Host" $host "FullName" $fullName "SvcPort" 7132 -}}
{{ include "redirect.hostRule" $host | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{ include "redirect.hostRule" (dict "Host" $host "FullName" $fullName "SvcPort" 7132) | nindent 4 }}
{{- end }}

0 comments on commit d8d05f4

Please sign in to comment.