[CORD-3003] Make XOS GUI optional (enabled by default)

Change-Id: I2b70ac628d7b5bf105de68895bb6cb0a22f93492
diff --git a/xos-gui/.helmignore b/xos-gui/.helmignore
new file mode 100644
index 0000000..f0c1319
--- /dev/null
+++ b/xos-gui/.helmignore
@@ -0,0 +1,21 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
diff --git a/xos-gui/Chart.yaml b/xos-gui/Chart.yaml
new file mode 100644
index 0000000..c60ee86
--- /dev/null
+++ b/xos-gui/Chart.yaml
@@ -0,0 +1,21 @@
+---
+# Copyright 2017-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.
+
+apiVersion: v1
+appVersion: "1.0"
+description: Web GUI for XOS
+name: xos-gui
+version: 0.1.0
+
diff --git a/xos-gui/templates/_helpers.tpl b/xos-gui/templates/_helpers.tpl
new file mode 100644
index 0000000..37909bc
--- /dev/null
+++ b/xos-gui/templates/_helpers.tpl
@@ -0,0 +1,57 @@
+{{- /*
+Copyright 2017-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.
+*/ -}}
+
+{{- define "xos-gui.release_labels" }}
+app: {{ printf "%s-%s" .Release.Name .Chart.Name | trunc 63 }}
+chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+release: {{ .Release.Name }}
+heritage: {{ .Release.Service }}
+version: {{ .Chart.Version }}
+{{- end }}
+
+{{- define "xos-gui.app_config" }}
+angular.module('app')
+.constant('AppConfig', {
+  apiEndpoint: '/xosapi/v1',
+  websocketClient: '/'
+});
+{{- end }}
+
+{{- define "xos-gui.style_config" }}
+angular.module('app')
+.constant('StyleConfig', {
+  projectName: 'R-CORD',
+  favicon: 'cord-favicon.png',
+  background: 'cord-bg.jpg',
+  payoff: 'Your VNF orchestrator',
+  logo: 'cord-logo.png',
+  routes: [
+      {
+          label: 'Slices',
+          state: 'xos.core.slice',
+      },
+      {
+          label: 'Nodes',
+          state: 'xos.core.node',
+      },
+      {
+          label: 'Instances',
+          state: 'xos.core.instance',
+      },
+  ]
+});
+{{- end }}
+
diff --git a/xos-gui/templates/_ws.tpl b/xos-gui/templates/_ws.tpl
new file mode 100644
index 0000000..09b77e4
--- /dev/null
+++ b/xos-gui/templates/_ws.tpl
@@ -0,0 +1,29 @@
+{{- /*
+Copyright 2017-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.
+*/ -}}
+
+{{- define "xos-ws.gateway_config" }}
+gateway_config:
+  default:
+  xos:
+    host: xost
+    port: 9000
+  redis:
+    host: redis
+    port: 6379
+  gateway:
+    port: 3000
+{{- end }}
+
diff --git a/xos-gui/templates/gui-configmap.yaml b/xos-gui/templates/gui-configmap.yaml
new file mode 100644
index 0000000..0e4a5c5
--- /dev/null
+++ b/xos-gui/templates/gui-configmap.yaml
@@ -0,0 +1,38 @@
+---
+# Copyright 2017-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.
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: gui-app-config
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+data:
+  config: |
+{{ include "xos-gui.app_config" . | indent 4 }}
+
+...
+---
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: gui-style-config
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+data:
+  config: |
+{{ include "xos-gui.style_config" . | indent 4 }}
+
diff --git a/xos-gui/templates/gui-deployment.yaml b/xos-gui/templates/gui-deployment.yaml
new file mode 100644
index 0000000..c00e073
--- /dev/null
+++ b/xos-gui/templates/gui-deployment.yaml
@@ -0,0 +1,60 @@
+---
+# Copyright 2017-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.
+
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-gui
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-gui
+    spec:
+      containers:
+        - name: xos-gui
+          image: {{ .Values.xos_guiImage | quote }}
+          imagePullPolicy: {{ .Values.imagePullPolicy }}
+          ports:
+            - containerPort: 4000
+              port: 4000
+              protocol: TCP
+          volumeMounts:
+            - name: style-config
+              mountPath: /var/www/dist/style.config.js
+              subPath: style/style.config.js
+            - name: app-config
+              mountPath: /var/www/dist/app.config.js
+              subPath: app/app.config.js
+            - name: extensions-volume
+              mountPath: /var/www/dist/extensions
+      volumes:
+        - name: style-config
+          configMap:
+            name: gui-style-config
+            items:
+              - key: config
+                path: style/style.config.js
+        - name: app-config
+          configMap:
+            name: gui-app-config
+            items:
+              - key: config
+                path: app/app.config.js
+        - name: extensions-volume
+          emptyDir: {}
diff --git a/xos-gui/templates/gui-service.yaml b/xos-gui/templates/gui-service.yaml
new file mode 100644
index 0000000..2504f58
--- /dev/null
+++ b/xos-gui/templates/gui-service.yaml
@@ -0,0 +1,30 @@
+---
+# Copyright 2017-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.
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-gui"
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+spec:
+  type: NodePort
+  ports:
+    - port: 4000
+      targetPort: 4000
+      nodePort: {{ .Values.xos_guiNodePort }}
+      protocol: TCP
+  selector:
+    app: "xos-gui"
diff --git a/xos-gui/templates/ws-configmap.yaml b/xos-gui/templates/ws-configmap.yaml
new file mode 100644
index 0000000..f2caa68
--- /dev/null
+++ b/xos-gui/templates/ws-configmap.yaml
@@ -0,0 +1,25 @@
+---
+# Copyright 2017-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.
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-ws
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+data:
+  config: |
+{{ include "xos-ws.gateway_config" . | indent 4 }}
+
diff --git a/xos-gui/templates/ws-deployment.yaml b/xos-gui/templates/ws-deployment.yaml
new file mode 100644
index 0000000..9d958bb
--- /dev/null
+++ b/xos-gui/templates/ws-deployment.yaml
@@ -0,0 +1,48 @@
+---
+# Copyright 2017-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.
+
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-ws
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-ws
+    spec:
+      containers:
+        - name: xos-ws
+          image: {{ .Values.xos_wsImage | quote }}
+          imagePullPolicy: {{ .Values.imagePullPolicy }}
+          command: ["npm", "start", "--", "--config", "gateway-config.yml"]
+          ports:
+            - containerPort: 3000
+              port: 3000
+              protocol: TCP
+          volumeMounts:
+            - name: gateway-config
+              mountPath: /var/www/src/config/gateway-config.yml
+              subPath: config/gateway-config.yml
+      volumes:
+        - name: gateway-config
+          configMap:
+            name: xos-ws
+            items:
+              - key: config
+                path: config/gateway-config.yml
diff --git a/xos-gui/templates/ws-service.yaml b/xos-gui/templates/ws-service.yaml
new file mode 100644
index 0000000..41c1a07
--- /dev/null
+++ b/xos-gui/templates/ws-service.yaml
@@ -0,0 +1,30 @@
+---
+# Copyright 2017-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.
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-ws"
+  labels:
+    {{- include "xos-gui.release_labels" . | indent 4 }}
+spec:
+  type: NodePort
+  ports:
+    - port: 3000
+      targetPort: 3000
+      nodePort: {{ .Values.xos_wsNodePort }}
+      protocol: TCP
+  selector:
+    app: "xos-ws"
diff --git a/xos-gui/values.yaml b/xos-gui/values.yaml
new file mode 100644
index 0000000..3449931
--- /dev/null
+++ b/xos-gui/values.yaml
@@ -0,0 +1,25 @@
+---
+# Copyright 2017-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.
+
+imagePullPolicy: 'IfNotPresent'
+
+# Docker Images
+xos_guiImage: 'xosproject/xos-gui:master'
+xos_wsImage: 'xosproject/xos-ws:master'
+
+# NodePorts
+xos_guiNodePort: 30001
+xos_wsNodePort: 30008
+