Initial Version of Helm Chart for OpenDaylight
[integration/packaging.git] / helm / opendaylight / templates / ingress.yaml
1 {{/*
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2021 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 */}}
12 {{- if .Values.ingress.enabled -}}
13 {{- $fullName := include "opendaylight.fullname" . -}}
14 {{- $svcPort := .Values.service.port -}}
15 {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
16   {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
17   {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
18   {{- end }}
19 {{- end }}
20 {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
21 apiVersion: networking.k8s.io/v1
22 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
23 apiVersion: networking.k8s.io/v1beta1
24 {{- else -}}
25 apiVersion: extensions/v1beta1
26 {{- end }}
27 kind: Ingress
28 metadata:
29   name: {{ $fullName }}
30   labels:
31     {{- include "opendaylight.labels" . | nindent 4 }}
32   {{- with .Values.ingress.annotations }}
33   annotations:
34     {{- toYaml . | nindent 4 }}
35   {{- end }}
36 spec:
37   {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
38   ingressClassName: {{ .Values.ingress.className }}
39   {{- end }}
40   {{- if .Values.ingress.tls }}
41   tls:
42     {{- range .Values.ingress.tls }}
43     - hosts:
44         {{- range .hosts }}
45         - {{ . | quote }}
46         {{- end }}
47       secretName: {{ .secretName }}
48     {{- end }}
49   {{- end }}
50   rules:
51     {{- range .Values.ingress.hosts }}
52     - host: {{ .host | quote }}
53       http:
54         paths:
55           {{- range .paths }}
56           - path: {{ .path }}
57             {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
58             pathType: {{ .pathType }}
59             {{- end }}
60             backend:
61               {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
62               service:
63                 name: {{ $fullName }}
64                 port:
65                   number: {{ $svcPort }}
66               {{- else }}
67               serviceName: {{ $fullName }}
68               servicePort: {{ $svcPort }}
69               {{- end }}
70           {{- end }}
71     {{- end }}
72 {{- end }}