58 lines
1.4 KiB
YAML
58 lines
1.4 KiB
YAML
{{/* vim: set filetype=mustache: */}}
|
|
|
|
{{- define "common.ingress.metadata" -}}
|
|
{{- $ingress := index . 1 }}
|
|
{{- with $ingress.annotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 2 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{- define "common.ingress.tpl" -}}
|
|
{{- $top := first . }}
|
|
{{- $ingress := index . 1 }}
|
|
{{- $service := index . 2 }}
|
|
{{- $fullName := include "common.fullname" $top }}
|
|
{{- $svcPort := $service.port }}
|
|
{{- if semverCompare ">=1.19.0" $top.Capabilities.KubeVersion.Version }}
|
|
apiVersion: networking.k8s.io/v1
|
|
{{- else if semverCompare ">=1.14.0" $top.Capabilities.KubeVersion.Version }}
|
|
apiVersion: networking.k8s.io/v1beta1
|
|
{{- else }}
|
|
apiVersion: extensions/v1beta1
|
|
{{- end }}
|
|
kind: Ingress
|
|
metadata:
|
|
{{- include "common.metadata" (append . "common.ingress.metadata") | nindent 2 }}
|
|
spec:
|
|
{{- if $ingress.tls }}
|
|
tls:
|
|
{{- range $ingress.tls }}
|
|
- hosts:
|
|
{{- range .hosts }}
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
secretName: {{ .secretName }}
|
|
{{- end }}
|
|
{{- end }}
|
|
rules:
|
|
{{- range $ingress.hosts }}
|
|
- host: {{ .host | quote }}
|
|
http:
|
|
paths:
|
|
{{- range .paths }}
|
|
- path: {{ . }}
|
|
backend:
|
|
serviceName: {{ $fullName }}
|
|
servicePort: {{ $svcPort }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{- define "common.ingress" -}}
|
|
{{- $ingress := index . 1 }}
|
|
{{- if $ingress.enabled }}
|
|
{{- include "common.utils.merge" (append . "common.ingress.tpl") }}
|
|
{{- end }}
|
|
{{- end }}
|