roc-umbrella: adding initial roc-gui-v2

Change-Id: I5cc0b40a8bdd86d9898950e2ba0a175e4118c1d4
diff --git a/aether-roc-gui-v2/templates/NOTES.txt b/aether-roc-gui-v2/templates/NOTES.txt
new file mode 100644
index 0000000..316f504
--- /dev/null
+++ b/aether-roc-gui-v2/templates/NOTES.txt
@@ -0,0 +1,22 @@
+# SPDX-FileCopyrightText: 2021 Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+Thank you for installing {{ .Chart.Name }} Helm chart.
+
+Your release is named {{ .Release.Name }} in namespace {{.Release.Namespace}}.
+See https://docs.onosproject.org/developers/deploy_with_helm/
+
+To learn more about the release, try:
+  $ helm -n {{.Release.Namespace}} status {{ .Release.Name }}
+  $ helm -n {{.Release.Namespace}} get all {{ .Release.Name }}
+
+{{ .Release.Name }} depends on the "aether-roc-api which in turn depends
+on onos-config(with the Aether x.y.0 model plugins) and onos-topo"
+micro services.
+
+If you are using KinD as a Kubernetes server you will have to add a "port-forward" to access the aether-roc-gui e.g.
+$ kubectl -n {{.Release.Namespace}} port-forward service/{{.Values.fullnameOverride}} 8183:80
+and then access the API with:
+
+http://localhost:8183
diff --git a/aether-roc-gui-v2/templates/_helpers.tpl b/aether-roc-gui-v2/templates/_helpers.tpl
new file mode 100644
index 0000000..8dd6a8c
--- /dev/null
+++ b/aether-roc-gui-v2/templates/_helpers.tpl
@@ -0,0 +1,66 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+Expand the name of the chart.
+*/}}
+{{- define "aether-roc-gui.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "aether-roc-gui.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "aether-roc-gui.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Common labels
+*/}}
+{{- define "aether-roc-gui.labels" -}}
+helm.sh/chart: {{ include "aether-roc-gui.chart" . }}
+{{ include "aether-roc-gui.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
+
+{{/*
+Selector labels
+*/}}
+{{- define "aether-roc-gui.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "aether-roc-gui.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end -}}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "aether-roc-gui.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create -}}
+    {{ default (include "aether-roc-gui.fullname" .) .Values.serviceAccount.name }}
+{{- else -}}
+    {{ default "default" .Values.serviceAccount.name }}
+{{- end -}}
+{{- end -}}
diff --git a/aether-roc-gui-v2/templates/configmap.yaml b/aether-roc-gui-v2/templates/configmap.yaml
new file mode 100644
index 0000000..0cf6ad2
--- /dev/null
+++ b/aether-roc-gui-v2/templates/configmap.yaml
@@ -0,0 +1,85 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ template "aether-roc-gui.fullname" . }}
+  namespace: {{ .Release.Namespace }}
+  labels:
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+data:
+  server-block.conf: |-
+    server {
+        listen {{.Values.Nginx.port}};
+        ssl_certificate /usr/share/certs/aether-roc-gui.crt;
+        ssl_certificate_key /usr/share/certs/aether-roc-gui.key;
+        {{- if .Values.websocket.proxyEnabled }}
+        location /ws {
+            proxy_pass {{ .Values.websocket.protocol }}://{{ .Values.websocket.service }}:{{ .Values.websocket.port }}/ws;
+            proxy_http_version 1.1;
+            proxy_set_header Upgrade $http_upgrade;
+            proxy_set_header Connection "Upgrade";
+            proxy_set_header Host $host;
+        }{{end}}
+        {{- if .Values.grafana.proxyEnabled }}
+        location /grafana/ {
+            proxy_pass {{ .Values.grafana.protocol }}://{{ .Values.grafana.service }}:{{ .Values.grafana.port }}/;
+            proxy_http_version 1.1;
+            proxy_redirect off;
+            proxy_set_header Upgrade $http_upgrade;
+            proxy_set_header Connection "Upgrade";
+            proxy_set_header X-Real-IP $remote_addr;
+            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+            proxy_set_header Host $http_host;
+            proxy_set_header X-NginX-Proxy true;
+            proxy_hide_header 'X-Frame-Options';
+            add_header X-Frame-Options SAMEORIGIN;
+        }{{end}}
+        {{- if .Values.prometheus.acc.proxyEnabled }}
+        location /prometheus-acc/ {
+            proxy_pass {{ .Values.prometheus.acc.protocol }}://{{ .Values.prometheus.acc.service }}:{{ .Values.prometheus.acc.port }}/;
+            proxy_http_version 1.1;
+            proxy_set_header Upgrade $http_upgrade;
+            add_header X-Frame-Options SAMEORIGIN;
+        }{{end}}
+        {{- if .Values.prometheus.amp.proxyEnabled }}
+        location /prometheus-amp/ {
+            proxy_pass {{ .Values.prometheus.amp.protocol }}://{{ .Values.prometheus.amp.service }}:{{ .Values.prometheus.amp.port }}/;
+            proxy_http_version 1.1;
+            proxy_set_header Upgrade $http_upgrade;
+            add_header X-Frame-Options SAMEORIGIN;
+        }{{end}}
+        {{- range $siteid, $site := .Values.prometheus.site }}
+        location /prometheus-{{$site.name}}/ {
+            proxy_pass {{ $site.protocol }}://{{ $site.service }}:{{ $site.port }}/;
+            proxy_http_version 1.1;
+            proxy_set_header Upgrade $http_upgrade;
+            add_header X-Frame-Options SAMEORIGIN;
+        }{{end}}
+        location / {
+          root /usr/share/nginx/html;
+        }
+        location /rs/nav/uiextensions {
+          root /usr/share/nginx/html;
+        }
+        location /kubernetes-api/ {
+            proxy_pass http://localhost:8001/;
+            proxy_http_version 1.1;
+        }
+        {{- range $key, $value := .Values.aetherservices }}
+        location /{{ $key }}/ {
+            proxy_pass {{ $value.protocol}}://{{$key}}:{{ $value.http }}/;
+            proxy_http_version 1.1;
+            proxy_set_header Upgrade $http_upgrade;
+            proxy_set_header Connection "Upgrade";
+            proxy_connect_timeout       {{ $value.streamTimeout }};
+            proxy_send_timeout          {{ $value.streamTimeout }};
+            proxy_read_timeout          {{ $value.streamTimeout }};
+            send_timeout                {{ $value.streamTimeout }};
+        }
+        {{ end }}
+    }
+
diff --git a/aether-roc-gui-v2/templates/deployment.yaml b/aether-roc-gui-v2/templates/deployment.yaml
new file mode 100644
index 0000000..cbb2601
--- /dev/null
+++ b/aether-roc-gui-v2/templates/deployment.yaml
@@ -0,0 +1,92 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ include "aether-roc-gui.fullname" . }}
+  namespace: {{ .Release.Namespace }}
+  labels:
+    {{- include "aether-roc-gui.labels" . | nindent 4 }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      name: {{ template "aether-roc-gui.fullname" . }}
+      app: aether
+      type: arg
+      resource: {{ template "aether-roc-gui.fullname" . }}
+      {{- include "aether-roc-gui.selectorLabels" . | nindent 6 }}
+  template:
+    metadata:
+      labels:
+        name: {{ template "aether-roc-gui.fullname" . }}
+        app: aether
+        type: arg
+        resource: {{ template "aether-roc-gui.fullname" . }}
+        {{- include "aether-roc-gui.selectorLabels" . | nindent 8 }}
+    spec:
+    {{- with .Values.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+    {{- end }}
+      securityContext:
+        {{- toYaml .Values.podSecurityContext | nindent 8 }}
+      containers:
+        - name: {{ .Chart.Name }}
+          securityContext:
+            {{- toYaml .Values.securityContext | nindent 12 }}
+          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          env:
+            - name: NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+            - name: OPENIDCISSUER
+              value: {{ .Values.openidc.issuer }}
+          stdin : true
+          resources:
+            {{- toYaml .Values.resources | nindent 12 }}
+          ports:
+            {{- with .Values.ports }}
+            {{- range $key, $port := . }}
+            - name: {{ $key }}
+              {{ toYaml $port | nindent 14 }}
+            {{- end }}
+            {{- end }}
+          livenessProbe:
+            tcpSocket:
+              port: web
+            initialDelaySeconds: 30
+          readinessProbe:
+            tcpSocket:
+              port: web
+            initialDelaySeconds: 30
+          volumeMounts:
+            - name: config
+              mountPath: /etc/nginx/conf.d
+            - name: secret
+              mountPath: /usr/share/certs
+              readOnly: true
+
+      volumes:
+        - name: config
+          configMap:
+            name: {{ template "aether-roc-gui.fullname" . }}
+        - name: secret
+          secret:
+            secretName: {{ template "aether-roc-gui.fullname" . }}-secret
+      {{- with .Values.nodeSelector }}
+      nodeSelector:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+    {{- with .Values.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+    {{- end }}
+    {{- with .Values.tolerations }}
+      tolerations:
+        {{- toYaml . | nindent 8 }}
+    {{- end }}
diff --git a/aether-roc-gui-v2/templates/ingress.yaml b/aether-roc-gui-v2/templates/ingress.yaml
new file mode 100644
index 0000000..986342e
--- /dev/null
+++ b/aether-roc-gui-v2/templates/ingress.yaml
@@ -0,0 +1,35 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+{{- if .Values.ingress.enabled }}
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: {{ template "aether-roc-gui.fullname" . }}-ingress
+  namespace: {{ .Release.Namespace }}
+  labels:
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+  annotations:
+    kubernetes.io/ingress.class: "nginx"
+    nginx.ingress.kubernetes.io/ssl-redirect: "false"
+    nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
+spec:
+  tls:
+    - secretName: {{ template "aether-roc-gui.fullname" . }}-secret
+      hosts:
+        - aether-roc-gui.onosproject.org
+  rules:
+    - host: aether-roc-gui.onosproject.org
+      http:
+        paths:
+          - pathType: Prefix
+            path: "/"
+            backend:
+              service:
+                name: {{ template "aether-roc-gui.fullname" . }}
+                port:
+                  number: {{ .Values.ports.web.containerPort }}
+{{- end }}
diff --git a/aether-roc-gui-v2/templates/role.yaml b/aether-roc-gui-v2/templates/role.yaml
new file mode 100644
index 0000000..1780115
--- /dev/null
+++ b/aether-roc-gui-v2/templates/role.yaml
@@ -0,0 +1,13 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+  namespace: {{ .Release.Namespace }}
+  name: {{ template "aether-roc-gui.fullname" . }}-service-role
+rules:
+  - apiGroups: [""] # "" indicates the core API group
+    resources: ["services"]
+    verbs: ["get", "watch", "list"]
diff --git a/aether-roc-gui-v2/templates/rolebinding.yaml b/aether-roc-gui-v2/templates/rolebinding.yaml
new file mode 100644
index 0000000..45b5ec1
--- /dev/null
+++ b/aether-roc-gui-v2/templates/rolebinding.yaml
@@ -0,0 +1,17 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+  name: {{ template "aether-roc-gui.fullname" . }}-access-services
+  namespace: {{ .Release.Namespace }}
+subjects:
+  - kind: ServiceAccount
+    name: default # Name is case sensitive
+    namespace: {{ .Release.Namespace }}
+roleRef:
+  kind: Role
+  name: {{ template "aether-roc-gui.fullname" . }}-service-role
+  apiGroup: rbac.authorization.k8s.io
diff --git a/aether-roc-gui-v2/templates/secret.yaml b/aether-roc-gui-v2/templates/secret.yaml
new file mode 100644
index 0000000..c047eed
--- /dev/null
+++ b/aether-roc-gui-v2/templates/secret.yaml
@@ -0,0 +1,18 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: Secret
+metadata:
+  name: {{ template "aether-roc-gui.fullname" . }}-secret
+  labels:
+     chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+     release: "{{ .Release.Name }}"
+     heritage: "{{ .Release.Service }}"
+data:
+  {{ $root := . }}
+  {{ range $path, $bytes := .Files.Glob "files/certs/*.*" }}
+  {{ base $path }}: '{{ $root.Files.Get $path | b64enc }}'
+  {{ end }}
+type: Opaque
diff --git a/aether-roc-gui-v2/templates/service.yaml b/aether-roc-gui-v2/templates/service.yaml
new file mode 100644
index 0000000..6faf652
--- /dev/null
+++ b/aether-roc-gui-v2/templates/service.yaml
@@ -0,0 +1,51 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ template "aether-roc-gui.fullname" . }}
+  labels:
+    app: {{ template "aether-roc-gui.fullname" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+    {{- include "aether-roc-gui.labels" . | nindent 4 }}
+spec:
+  type: {{ .Values.service.type }}
+  selector:
+    name: {{ template "aether-roc-gui.fullname" . }}
+    app: aether
+    type: arg
+    resource: {{ template "aether-roc-gui.fullname" . }}
+    {{- include "aether-roc-gui.selectorLabels" . | nindent 4 }}
+  ports:
+    - name: web
+      port: 80
+---
+{{- if .Values.service.external.nodePort }}
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ template "aether-roc-gui.fullname" . }}-external
+  labels:
+    app: {{ template "aether-roc-gui.fullname" . }}
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    release: "{{ .Release.Name }}"
+    heritage: "{{ .Release.Service }}"
+    {{- include "aether-roc-gui.labels" . | nindent 4 }}
+spec:
+  type: NodePort
+  selector:
+    name: {{ template "aether-roc-gui.fullname" . }}
+    app: aether
+    type: arg
+    resource: {{ template "aether-roc-gui.fullname" . }}
+    {{- include "aether-roc-gui.selectorLabels" . | nindent 4 }}
+  ports:
+    - name: web
+      port: 80
+      nodePort: {{ .Values.service.external.nodePort }}
+      protocol: TCP
+{{- end }}