VOL-3958 support for ingress in helm charts
Change-Id: I8c53016debb11760dd8ae39e8662ba0489d705a9
diff --git a/voltha/Chart.yaml b/voltha/Chart.yaml
index 074d271..7a7e54f 100644
--- a/voltha/Chart.yaml
+++ b/voltha/Chart.yaml
@@ -14,7 +14,7 @@
---
apiVersion: "v1"
name: "voltha"
-version: "2.9.0-dev"
+version: "2.9.0"
description: "A Helm chart for Voltha based on K8S resources in Voltha project"
keywords:
- "onf"
diff --git a/voltha/templates/_helpers.tpl b/voltha/templates/_helpers.tpl
index bf89b45..0fd902b 100644
--- a/voltha/templates/_helpers.tpl
+++ b/voltha/templates/_helpers.tpl
@@ -21,3 +21,9 @@
{{- $fullname := default (printf "%s-%s" .Release.Name $name) .Values.fullNameOverride -}}
{{- $fullname | trunc 63 | trimSuffix "-" -}}
{{- end -}}
+{{/* Create a default fully qualified virtual hostname. We truncate at 63 chars because . . . */}}
+{{- define "virtual-hostname" -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- $fullname := default (printf "%s.%s.local" .Values.global.stack_name $name) .Values.fullNameOverride -}}
+{{- $fullname | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
diff --git a/voltha/templates/ingress.yaml b/voltha/templates/ingress.yaml
new file mode 100644
index 0000000..69d161c
--- /dev/null
+++ b/voltha/templates/ingress.yaml
@@ -0,0 +1,64 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+{{- if .Values.ingress.enabled -}}
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: {{ template "fullname" . }}
+ namespace: {{ .Release.Namespace }}
+ {{- with .Values.labels }}
+ labels:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ {{- if $.Values.ingress.enableVirtualHosts }}
+ - host: '{{ template "virtual-hostname" $ }}'
+ http:
+ {{- else }}
+ {{- if .host }}
+ - host: {{ .host | quote }}
+ http:
+ {{- else }}
+ - http:
+ {{- end }}
+ {{- end }}
+ paths:
+ {{- range .paths }}
+ - path: {{ . }}
+ pathType: Prefix
+ backend:
+ service:
+ name: "{{ template "fullname" $ }}-api"
+ port:
+ number: 55555
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/voltha/values.yaml b/voltha/values.yaml
index 433a67e..e7e5879 100644
--- a/voltha/values.yaml
+++ b/voltha/values.yaml
@@ -99,3 +99,17 @@
repository: '{{ .Values.global.image_org }}voltha-rw-core'
tag: '{{- if hasKey .Values.global "image_tag" }}{{- if .Values.global.image_tag }}{{ .Values.global.image_tag }}{{- else }}2.7.0{{- end }}{{- else }}2.7.0{{- end }}'
pullPolicy: '{{ .Values.global.image_pullPolicy }}'
+
+ingress:
+ enabled: false
+ annotations:
+ kubernetes.io/ingress.class: "nginx"
+ nginx.ingress.kubernetes.io/ssl-redirect: "true"
+ nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
+ nginx.ingress.kubernetes.io/grpc-backend: "true"
+ enableVirtualHosts: false
+ hosts:
+ - host:
+ paths:
+ - "/voltha.VolthaService/"
+ tls: []