Vhosts support to the common ingress template 72/96672/8
authorLucjan Bryndza <l.bryndza@samsung.com>
Mon, 7 Oct 2019 12:19:51 +0000 (12:19 +0000)
committerLucjan Bryndza <l.bryndza@samsung.com>
Tue, 3 Dec 2019 09:05:43 +0000 (10:05 +0100)
Add virtual hosting support to the ingress
common template
Added support for global configuration path
or virtual host based

Signed-off-by: Lucjan Bryndza <l.bryndza@samsung.com>
Change-Id: I6b1a0c9cfd0eb5c90a090058d5db70f8ee33731e
Issue-ID: OOM-2125
Signed-off-by: Lucjan Bryndza <l.bryndza@samsung.com>
kubernetes/common/common/templates/_ingress.tpl
kubernetes/onap/values.yaml

index 49d7eeb..b4afe63 100644 (file)
@@ -1,12 +1,24 @@
 {{- define "ingress.config.port" -}}
 {{- if .Values.ingress -}}
-{{- if .Values.ingress.service -}}
+{{- if or (not .Values.global.ingress.virtualhost) (not .Values.global.ingress.virtualhost.enabled) -}}
+  - http:
+      paths:
 {{- range .Values.ingress.service }}
-        - path: {{ .path }}
+        - path: {{  printf "/%s" (required "baseaddr" .baseaddr) }}
           backend:
             serviceName: {{ .name }}
             servicePort: {{ .port }}
 {{- end -}}
+{{- else if .Values.ingress.service -}}
+{{- $burl := (required "baseurl" .Values.global.ingress.virtualhost.baseurl) -}}
+{{ range .Values.ingress.service }}
+  - host: {{ printf "%s.%s" (required "baseaddr" .baseaddr) $burl }}
+    http:
+      paths:
+      - backend:
+          serviceName: {{ .name }}
+          servicePort: {{ .port }}
+{{- end -}}
 {{- else -}}
         - path: {{ printf "/%s" .Chart.Name }}
           backend:
 {{- end -}}
 
 
+{{- define "ingress.config.annotations.ssl" -}}
+{{- if .Values.ingress.config -}}
+{{- if .Values.ingress.config.ssl -}}
+{{- if eq .Values.ingress.config.ssl "redirect" -}}
+kubernetes.io/ingress.class: nginx
+nginx.ingress.kubernetes.io/ssl-passthrough: "true"
+nginx.ingress.kubernetes.io/ssl-redirect: "true"
+{{-  else if eq .Values.ingress.config.ssl "native" -}}
+nginx.ingress.kubernetes.io/ssl-redirect: "true"
+{{-  else if eq .Values.ingress.config.ssl "none" -}}
+nginx.ingress.kubernetes.io/ssl-redirect: "false"
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+
 {{- define "ingress.config.annotations" -}}
 {{- if .Values.ingress -}}
 {{- if .Values.ingress.annotations -}}
 {{ toYaml .Values.ingress.annotations | indent 4 | trim }}
 {{- end -}}
 {{- end -}}
+{{ include "ingress.config.annotations.ssl" . | indent 4 | trim }}
 {{- end -}}
 
 
 {{- define "common.ingress" -}}
 {{- if .Values.ingress -}}
-{{- if .Values.ingress.enabled -}}
+{{- if .Values.global.ingress -}}
+{{- if and .Values.ingress.enabled .Values.global.ingress.enabled -}}
 apiVersion: extensions/v1beta1
 kind: Ingress
 metadata:
@@ -42,9 +73,7 @@ metadata:
     heritage: {{ .Release.Service }}
 spec:
   rules:
-  - http:
-      paths:
-        {{- include "ingress.config.port" . }}
+  {{ include "ingress.config.port" . | trim }}
 {{- if .Values.ingress.tls }}
   tls:
 {{ toYaml .Values.ingress.tls | indent 4 }}
@@ -52,4 +81,4 @@ spec:
 {{- end -}}
 {{- end -}}
 {{- end -}}
-
+{{- end -}}
\ No newline at end of file
index 672ae2e..af8456a 100755 (executable)
@@ -57,6 +57,12 @@ global:
   # flag to enable debugging - application support required
   debugEnabled: false
 
+  #Global ingress configuration
+  ingress:
+    enabled: false
+    virtualhost:
+        enabled: true
+        baseurl: "simpledemo.onap.org"
 #################################################################
 # Enable/disable and configure helm charts (ie. applications)
 # to customize the ONAP deployment.
@@ -169,4 +175,4 @@ vid:
 vnfsdk:
   enabled: false
 modeling:
-  enabled: false
+  enabled: false
\ No newline at end of file