Hyunsun Moon | 97e111d | 2022-05-13 17:56:56 -0700 | [diff] [blame^] | 1 | {{/* |
| 2 | # Copyright 2022-present Open Networking Foundation |
| 3 | |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | */}} |
Shad Ansari | 0a4637a | 2022-05-11 12:20:59 -0700 | [diff] [blame] | 6 | |
| 7 | {{- if .Values.ingress.enabled -}} |
| 8 | {{- $fullName := include "person-detection-app.fullname" . -}} |
| 9 | {{- $svcPort := .Values.service.port -}} |
| 10 | {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} |
| 11 | {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} |
| 12 | {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} |
| 13 | {{- end }} |
| 14 | {{- end }} |
| 15 | {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} |
| 16 | apiVersion: networking.k8s.io/v1 |
| 17 | {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} |
| 18 | apiVersion: networking.k8s.io/v1beta1 |
| 19 | {{- else -}} |
| 20 | apiVersion: extensions/v1beta1 |
| 21 | {{- end }} |
| 22 | kind: Ingress |
| 23 | metadata: |
| 24 | name: {{ $fullName }} |
| 25 | labels: |
| 26 | {{- include "person-detection-app.labels" . | nindent 4 }} |
| 27 | {{- with .Values.ingress.annotations }} |
| 28 | annotations: |
| 29 | {{- toYaml . | nindent 4 }} |
| 30 | {{- end }} |
| 31 | spec: |
| 32 | {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} |
| 33 | ingressClassName: {{ .Values.ingress.className }} |
| 34 | {{- end }} |
| 35 | {{- if .Values.ingress.tls }} |
| 36 | tls: |
| 37 | {{- range .Values.ingress.tls }} |
| 38 | - hosts: |
| 39 | {{- range .hosts }} |
| 40 | - {{ . | quote }} |
| 41 | {{- end }} |
| 42 | secretName: {{ .secretName }} |
| 43 | {{- end }} |
| 44 | {{- end }} |
| 45 | rules: |
| 46 | {{- range .Values.ingress.hosts }} |
| 47 | - host: {{ .host | quote }} |
| 48 | http: |
| 49 | paths: |
| 50 | {{- range .paths }} |
| 51 | - path: {{ .path }} |
| 52 | {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} |
| 53 | pathType: {{ .pathType }} |
| 54 | {{- end }} |
| 55 | backend: |
| 56 | {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} |
| 57 | service: |
| 58 | name: {{ $fullName }} |
| 59 | port: |
| 60 | number: {{ $svcPort }} |
| 61 | {{- else }} |
| 62 | serviceName: {{ $fullName }} |
| 63 | servicePort: {{ $svcPort }} |
| 64 | {{- end }} |
| 65 | {{- end }} |
| 66 | {{- end }} |
| 67 | {{- end }} |