b4afe6309df2a28dc54638c604ab73a23ac0f81b
[it/dep.git] / smo-install / oran_oom / aux-common / templates / _ingress.tpl
1 {{- define "ingress.config.port" -}}
2 {{- if .Values.ingress -}}
3 {{- if or (not .Values.global.ingress.virtualhost) (not .Values.global.ingress.virtualhost.enabled) -}}
4   - http:
5       paths:
6 {{- range .Values.ingress.service }}
7         - path: {{  printf "/%s" (required "baseaddr" .baseaddr) }}
8           backend:
9             serviceName: {{ .name }}
10             servicePort: {{ .port }}
11 {{- end -}}
12 {{- else if .Values.ingress.service -}}
13 {{- $burl := (required "baseurl" .Values.global.ingress.virtualhost.baseurl) -}}
14 {{ range .Values.ingress.service }}
15   - host: {{ printf "%s.%s" (required "baseaddr" .baseaddr) $burl }}
16     http:
17       paths:
18       - backend:
19           serviceName: {{ .name }}
20           servicePort: {{ .port }}
21 {{- end -}}
22 {{- else -}}
23         - path: {{ printf "/%s" .Chart.Name }}
24           backend:
25             serviceName: {{ .Chart.Name }}
26             servicePort: {{ .Values.service.externalPort }}
27 {{- end -}}
28 {{- end -}}
29 {{- end -}}
30
31
32 {{- define "ingress.config.annotations.ssl" -}}
33 {{- if .Values.ingress.config -}}
34 {{- if .Values.ingress.config.ssl -}}
35 {{- if eq .Values.ingress.config.ssl "redirect" -}}
36 kubernetes.io/ingress.class: nginx
37 nginx.ingress.kubernetes.io/ssl-passthrough: "true"
38 nginx.ingress.kubernetes.io/ssl-redirect: "true"
39 {{-  else if eq .Values.ingress.config.ssl "native" -}}
40 nginx.ingress.kubernetes.io/ssl-redirect: "true"
41 {{-  else if eq .Values.ingress.config.ssl "none" -}}
42 nginx.ingress.kubernetes.io/ssl-redirect: "false"
43 {{- end -}}
44 {{- end -}}
45 {{- end -}}
46 {{- end -}}
47
48
49 {{- define "ingress.config.annotations" -}}
50 {{- if .Values.ingress -}}
51 {{- if .Values.ingress.annotations -}}
52 {{ toYaml .Values.ingress.annotations | indent 4 | trim }}
53 {{- end -}}
54 {{- end -}}
55 {{ include "ingress.config.annotations.ssl" . | indent 4 | trim }}
56 {{- end -}}
57
58
59 {{- define "common.ingress" -}}
60 {{- if .Values.ingress -}}
61 {{- if .Values.global.ingress -}}
62 {{- if and .Values.ingress.enabled .Values.global.ingress.enabled -}}
63 apiVersion: extensions/v1beta1
64 kind: Ingress
65 metadata:
66   name: {{ include "common.fullname" . }}-ingress
67   annotations:
68     {{ include "ingress.config.annotations" . }}
69   labels:
70     app: {{ .Chart.Name }}
71     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
72     release: {{ .Release.Name }}
73     heritage: {{ .Release.Service }}
74 spec:
75   rules:
76   {{ include "ingress.config.port" . | trim }}
77 {{- if .Values.ingress.tls }}
78   tls:
79 {{ toYaml .Values.ingress.tls | indent 4 }}
80   {{- end -}}
81 {{- end -}}
82 {{- end -}}
83 {{- end -}}
84 {{- end -}}