Hangar/chart/templates/ingress.yaml
2023-01-05 20:27:45 +01:00

50 lines
1.6 KiB
YAML

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "hangar.fullname" . -}}
{{- $frontendSvcPort := .Values.frontend.service.port -}}
{{- $backendSvcPort := .Values.backend.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "hangar.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ .Values.ingress.host | quote }}
http:
paths:
{{- range .Values.ingress.paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}-{{ .target }}
port:
{{- if eq "frontend" .target }}
number: {{ $frontendSvcPort}}
{{- else}}
number: {{ $backendSvcPort}}
{{- end}}
{{- end }}
{{- end }}