Upgrade ingress template

Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
This commit is contained in:
Martyn 2021-11-21 14:25:32 +01:00
parent 14b552a81a
commit 8648c9aa8e
2 changed files with 30 additions and 18 deletions

View File

@ -1,41 +1,51 @@
{{- if .Values.ingress.enabled -}} {{- if .Values.ingress.enabled -}}
{{- $fullName := include "wkd4pgp.fullname" . -}} {{- $fullName := include "wkd4pgp.fullname" . -}}
{{- $svcPort := .Values.service.port -}} {{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} {{- $version := "extensions/v1beta1" -}}
apiVersion: networking.k8s.io/v1beta1 {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
{{- else -}} {{- $version = "networking.k8s.io/v1" -}}
apiVersion: extensions/v1beta1 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- end }} {{- $version = "networking.k8s.io/v1beta1" -}}
{{- end -}}
apiVersion: {{ $version }}
kind: Ingress kind: Ingress
metadata: metadata:
name: {{ $fullName }} name: {{ $fullName }}
labels: labels:
{{ include "wkd4pgp.labels" . | indent 4 }} {{- include "wkd4pgp.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }} {{- with .Values.ingress.annotations }}
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.ingress.tls }} {{- if .Values.ingress.tls }}
tls: tls:
{{- range .Values.ingress.tls }} {{- range .Values.ingress.tls }}
- hosts: - hosts:
{{- range .hosts }} {{- range .hosts }}
- {{ . | quote }} - {{ . | quote }}
{{- end }} {{- end }}
secretName: {{ .secretName }} secretName: {{ .secretName }}
{{- end }}
{{- end }} {{- end }}
{{- end }}
rules: rules:
{{- range .Values.ingress.hosts }} {{- range .Values.ingress.hosts }}
- host: {{ .host | quote }} - host: {{ .host | quote }}
http: http:
paths: paths:
{{- range .paths }} {{- range .paths }}
- path: {{ . }} - path: {{ .path }}
pathType: {{ .pathType }}
backend: backend:
{{- if eq $version "networking.k8s.io/v1" }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else -}}
serviceName: {{ $fullName }} serviceName: {{ $fullName }}
servicePort: {{ $svcPort }} servicePort: {{ $svcPort }}
{{- end }} {{- end -}}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- end }}

View File

@ -45,10 +45,12 @@ ingress:
hosts: hosts:
- host: rtyn.berlin - host: rtyn.berlin
paths: paths:
- /.well-known/openpgpkey/ - path: /.well-known/openpgpkey/
pathType: Prefix
- host: openpgpkey.rtyn.berlin - host: openpgpkey.rtyn.berlin
paths: paths:
- /.well-known/openpgpkey/ - path: /.well-known/openpgpkey/
pathType: Prefix
tls: tls:
- secretName: chart-example-tls - secretName: chart-example-tls