XOS Core complete helm initial submission

Change-Id: I2fc7ae7d06f98c0c7578df7b21a21163b13dfca1
diff --git a/xos-core/Chart.yaml b/xos-core/Chart.yaml
new file mode 100644
index 0000000..40a1708
--- /dev/null
+++ b/xos-core/Chart.yaml
@@ -0,0 +1,2 @@
+name: xos-core
+version: 1.0.0
diff --git a/xos-core/templates/_helpers.tpl b/xos-core/templates/_helpers.tpl
new file mode 100644
index 0000000..399c79a
--- /dev/null
+++ b/xos-core/templates/_helpers.tpl
@@ -0,0 +1,8 @@
+{{- define "xos-core.release_labels" }}
+app: {{ printf "%s-%s" .Release.Name .Chart.Name | trunc 63 }}
+version: {{ .Chart.Version }}
+release: {{ .Release.Name }}
+{{- end }}
+{{- define "xos-core.full_name" -}}
+{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 -}}
+{{- end -}}
diff --git a/xos-core/templates/certchain-secret.yaml b/xos-core/templates/certchain-secret.yaml
new file mode 100644
index 0000000..3441992
--- /dev/null
+++ b/xos-core/templates/certchain-secret.yaml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: cert-chain-secret
+  namespace: default
+type: Opaque
+data:
+  local_certs.crt: {{ .Values.secrets.im_cert_chain }}
\ No newline at end of file
diff --git a/xos-core/templates/chameleon-deployment.yaml b/xos-core/templates/chameleon-deployment.yaml
new file mode 100644
index 0000000..536b4a2
--- /dev/null
+++ b/xos-core/templates/chameleon-deployment.yaml
@@ -0,0 +1,21 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-chameleon
+  labels:
+    app: xos-chameleon    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-chameleon
+    spec:
+      containers:
+        - name: xos-chameleon
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.xos_chameleon.repository }}:{{ .Values.images.xos_chameleon.tag }}
+          command: ["python chameleon/chameleon/main.py -R 9101 -G xos-core:50055 --swagger-url /apidocs -r"]
+          ports:
+            - containerPort: 9101
+              port: 9101
+              protocol: TCP
\ No newline at end of file
diff --git a/xos-core/templates/chameleon-service.yaml b/xos-core/templates/chameleon-service.yaml
new file mode 100644
index 0000000..0b9da59
--- /dev/null
+++ b/xos-core/templates/chameleon-service.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-chameleon"
+spec:
+  type: NodePort
+  ports:
+  - port: 9101
+    targetPort: 9101 
+    protocol: TCP
+  selector:
+    app: "xos-chameleon"
diff --git a/xos-core/templates/core-configmap.yaml b/xos-core/templates/core-configmap.yaml
new file mode 100644
index 0000000..886a0f5
--- /dev/null
+++ b/xos-core/templates/core-configmap.yaml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-core
+  # labels:
+  #   {{- include "xos-core.release_labels" . | indent 4 }}
+data:
+  config: {{ .Values.configs.core_config }}
diff --git a/xos-core/templates/core-deployment.yaml b/xos-core/templates/core-deployment.yaml
new file mode 100644
index 0000000..b9e2c16
--- /dev/null
+++ b/xos-core/templates/core-deployment.yaml
@@ -0,0 +1,60 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-core
+  labels:
+    app: xos-core    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-core    
+    spec:
+      containers:
+        - name: xos-core 
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.xos_core.repository }}:{{ .Values.images.xos_core.tag }}
+          command: ["/bin/bash", "-c", "cd coreapi; ./start_coreapi.sh"]
+          ports:
+            - containerPort: 50051
+              port: 50051
+              protocol: TCP
+            - containerPort: 50055
+              port: 50055
+              protocol: TCP
+          volumeMounts:
+            - name: certchain-volume
+              mountPath: /usr/local/share/ca-certificates
+            - name: coreapi-volume
+              mountPath: /opt/cord_profile
+              readOnly: true
+            - name: xos-core-config
+              mountPath: /opt/xos/xos_config.yaml
+              subPath: config/xos_config.yaml
+            - name: initial-data-config
+              mountPath: /opt/xos/core/migrations/initial_data.yaml
+              subPath: migrations/initial_data.yaml
+      volumes:
+        - name: certchain-volume
+          secret:
+            secretName: cert-chain-secret
+        - name: coreapi-volume
+          secret:
+            secretName: coreapi-cert-secret
+            items:
+            - key: core_api_cert.pem
+              path: coreapisecret/core_api_cert.pem
+            - key: core_api_key.pem
+              path: coreapisecret/core_api_key.pem
+        - name: xos-core-config
+          configMap:
+            name: xos-core 
+            items: 
+             - key: config
+               path: config/xos_config.yaml
+        - name: initial-data-config
+          configMap:
+            name: xos-initial-data 
+            items: 
+             - key: config
+               path: migrations/initial_data.yaml
diff --git a/xos-core/templates/core-service.yaml b/xos-core/templates/core-service.yaml
new file mode 100644
index 0000000..7e56013
--- /dev/null
+++ b/xos-core/templates/core-service.yaml
@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-core"
+  labels:
+    {{- include "xos-core.release_labels" . | indent 4 }}
+spec:
+  type: NodePort
+  ports:
+  - port: 50051
+    name: secure 
+    targetPort: 50051 
+    protocol: TCP
+  - port: 50055
+    name: insecure 
+    targetPort: 50055 
+    protocol: TCP
+  selector:
+    app: "xos-core"
diff --git a/xos-core/templates/coreapi-cert-secret.yaml b/xos-core/templates/coreapi-cert-secret.yaml
new file mode 100644
index 0000000..a79c84e
--- /dev/null
+++ b/xos-core/templates/coreapi-cert-secret.yaml
@@ -0,0 +1,9 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: coreapi-cert-secret
+  namespace: default
+type: kubernetes.io/tls
+data:
+  core_api_cert.pem: {{ .Values.secrets.core_api_cert }}
+  core_api_key.pem: {{ .Values.secrets.core_api_key }}
diff --git a/xos-core/templates/db-configmap.yaml b/xos-core/templates/db-configmap.yaml
new file mode 100644
index 0000000..45183b2
--- /dev/null
+++ b/xos-core/templates/db-configmap.yaml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-db
+  labels:
+    {{- include "xos-core.release_labels" . | indent 4 }}
+data:
+  service_5432_name: 'xos-db'
diff --git a/xos-core/templates/db-deployment.yaml b/xos-core/templates/db-deployment.yaml
new file mode 100644
index 0000000..ca34b69
--- /dev/null
+++ b/xos-core/templates/db-deployment.yaml
@@ -0,0 +1,27 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-db
+  labels:
+    app: xos-db    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-db    
+      annotations:
+        checksum/config-map: {{ include (print $.Chart.Name "/templates/db-configmap.yaml") . | sha256sum }}
+    spec:
+      containers:
+        - name: xos-db 
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.xos_db.repository }}:{{ .Values.images.xos_db.tag }}
+          ports:
+            - containerPort: 5432 
+              protocol: TCP
+          env:
+            - name: SERVICE_5432_NAME
+              valueFrom:
+                configMapKeyRef:
+                  name: xos-db
+                  key: service_5432_name
diff --git a/xos-core/templates/db-service.yaml b/xos-core/templates/db-service.yaml
new file mode 100644
index 0000000..8afaf64
--- /dev/null
+++ b/xos-core/templates/db-service.yaml
@@ -0,0 +1,14 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-db"
+  labels:
+    {{- include "xos-core.release_labels" . | indent 4 }}
+spec:
+  type: NodePort
+  ports:
+  - port: 5432 
+    targetPort: 5432 
+    protocol: TCP
+  selector:
+    app: "xos-db"
diff --git a/xos-core/templates/gateway-configmap.yaml b/xos-core/templates/gateway-configmap.yaml
new file mode 100644
index 0000000..d29b4b3
--- /dev/null
+++ b/xos-core/templates/gateway-configmap.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-gateway
+data:
+  config: {{ .Values.configs.gateway_config }}
diff --git a/xos-core/templates/gui-app-configmap.yaml b/xos-core/templates/gui-app-configmap.yaml
new file mode 100644
index 0000000..d387b77
--- /dev/null
+++ b/xos-core/templates/gui-app-configmap.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-app-config
+data:
+  config: {{ .Values.configs.gui_app_config }}
diff --git a/xos-core/templates/gui-deployment.yaml b/xos-core/templates/gui-deployment.yaml
new file mode 100644
index 0000000..57f4351
--- /dev/null
+++ b/xos-core/templates/gui-deployment.yaml
@@ -0,0 +1,44 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-gui
+  labels:
+    app: xos-gui    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-gui    
+    spec:
+      containers:
+        - name: xos-gui 
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.xos_gui.repository }}:{{ .Values.images.xos_gui.tag }}
+          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: xos-style-config 
+            items: 
+             - key: config
+               path: style/style.config.js
+        - name: app-config
+          configMap:
+            name: xos-app-config 
+            items: 
+             - key: config
+               path: app/app.config.js
+        - name: extensions-volume
+            emptyDir: {}
diff --git a/xos-core/templates/gui-service.yaml b/xos-core/templates/gui-service.yaml
new file mode 100644
index 0000000..ccf6c83
--- /dev/null
+++ b/xos-core/templates/gui-service.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-gui"
+spec:
+  type: NodePort
+  ports:
+  - port: 4000
+    targetPort: 4000 
+    protocol: TCP
+  selector:
+    app: "xos-gui"
diff --git a/xos-core/templates/gui-style-configmap.yaml b/xos-core/templates/gui-style-configmap.yaml
new file mode 100644
index 0000000..88a1413
--- /dev/null
+++ b/xos-core/templates/gui-style-configmap.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-style-config
+data:
+  config: {{ .Values.configs.gui_style_config }}
diff --git a/xos-core/templates/guiextensionstore-deployment.yaml b/xos-core/templates/guiextensionstore-deployment.yaml
new file mode 100644
index 0000000..bc33061
--- /dev/null
+++ b/xos-core/templates/guiextensionstore-deployment.yaml
@@ -0,0 +1,23 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-guiextensionstore
+  labels:
+    app: xos-guiextensionstore    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-guiextensionstore    
+    spec:
+      containers:
+        - name: xos-guiextensionstore 
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.node.repository }}:{{ .Values.images.node.tag }}
+          command: ["/bin/true"]
+          volumeMounts:
+            - name: extensions-volume
+              mountPath: /var/www/dist/extensions
+      volumes:
+        - name: extensions-volume
+            emptyDir: {}
diff --git a/xos-core/templates/initial-data-configmap.yaml b/xos-core/templates/initial-data-configmap.yaml
new file mode 100644
index 0000000..e7b61c6
--- /dev/null
+++ b/xos-core/templates/initial-data-configmap.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-initial-data
+data:
+  config: {{ .Values.configs.initial_data_config }}
diff --git a/xos-core/templates/redis-deployment.yaml b/xos-core/templates/redis-deployment.yaml
new file mode 100644
index 0000000..38a9c8b
--- /dev/null
+++ b/xos-core/templates/redis-deployment.yaml
@@ -0,0 +1,20 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-redis
+  labels:
+    app: xos-redis    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-redis
+    spec:
+      containers:
+        - name: xos-redis
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.redis.repository }}:{{ .Values.images.redis.tag }}
+          ports:
+            - containerPort: 6379
+              port: 6379 
+              protocol: TCP
\ No newline at end of file
diff --git a/xos-core/templates/redis-service.yaml b/xos-core/templates/redis-service.yaml
new file mode 100644
index 0000000..47e9a38
--- /dev/null
+++ b/xos-core/templates/redis-service.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "redis"
+spec:
+  type: NodePort
+  ports:
+  - port: 6379
+    targetPort: 6379 
+    protocol: TCP
+  selector:
+    app: "xos-redis"
diff --git a/xos-core/templates/tosca-configmap.yaml b/xos-core/templates/tosca-configmap.yaml
new file mode 100644
index 0000000..f20b859
--- /dev/null
+++ b/xos-core/templates/tosca-configmap.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: xos-tosca
+data:
+  config: {{ .Values.configs.tosca_config }}
diff --git a/xos-core/templates/tosca-deployment.yaml b/xos-core/templates/tosca-deployment.yaml
new file mode 100644
index 0000000..f4c4ab8
--- /dev/null
+++ b/xos-core/templates/tosca-deployment.yaml
@@ -0,0 +1,36 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-tosca
+  labels:
+    app: xos-tosca    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-tosca    
+    spec:
+      containers:
+        - name: xos-tosca 
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.xos_tosca.repository }}:{{ .Values.images.xos_tosca.tag }}
+          ports:
+            - containerPort: 9102
+              port: 9102 
+              protocol: TCP
+          volumeMounts:
+            - name: secret-volume
+              mountPath: /usr/local/share/ca-certificates
+            - name: xos-core-config
+              mountPath: /opt/xos-tosca/src/xos-tosca.config.yaml
+              subPath: config/xos-tosca.config.yaml
+      volumes:
+        - name: secret-volume
+          secret:
+            secretName: cert-chain-secret
+        - name: xos-core-config
+          configMap:
+            name: xos-tosca 
+            items: 
+             - key: config
+               path: config/xos-tosca.config.yaml
diff --git a/xos-core/templates/tosca-service.yaml b/xos-core/templates/tosca-service.yaml
new file mode 100644
index 0000000..5fdfbef
--- /dev/null
+++ b/xos-core/templates/tosca-service.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-tosca"
+spec:
+  type: NodePort
+  ports:
+  - port: 9102
+    targetPort: 9102 
+    protocol: TCP
+  selector:
+    app: "xos-tosca"
diff --git a/xos-core/templates/ws-deployment.yaml b/xos-core/templates/ws-deployment.yaml
new file mode 100644
index 0000000..8b3a41d
--- /dev/null
+++ b/xos-core/templates/ws-deployment.yaml
@@ -0,0 +1,32 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: xos-ws
+  labels:
+    app: xos-ws    
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: xos-ws
+    spec:
+      containers:
+        - name: xos-ws
+          image: {{ .Values.pull_docker_registry }}{{ .Values.images.xos_ws.repository }}:{{ .Values.images.xos_ws.tag }}
+          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-gateway 
+            items: 
+             - key: config
+               path: config/gateway-config.yml
\ No newline at end of file
diff --git a/xos-core/templates/ws-service.yaml b/xos-core/templates/ws-service.yaml
new file mode 100644
index 0000000..b3374c3
--- /dev/null
+++ b/xos-core/templates/ws-service.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: "xos-ws"
+spec:
+  type: NodePort
+  ports:
+  - port: 3000
+    targetPort: 3000 
+    protocol: TCP
+  selector:
+    app: "xos-ws"
diff --git a/xos-core/values.yaml b/xos-core/values.yaml
new file mode 100644
index 0000000..bbedada
--- /dev/null
+++ b/xos-core/values.yaml
@@ -0,0 +1,69 @@
+pull_docker_registry: docker-registry:5000/
+
+images:
+  xos_core:
+    repository: xosproject/xos-ui
+    tag: 'latest'
+  xos_gui:
+    repository: xosproject/xos-gui
+    tag: 'latest'
+  xos_db:
+    repository: xosproject/xos-postgres
+    tag: 'latest'
+  xos_tosca:
+    repository: xosproject/xos-tosca
+    tag: 'latest'
+  xos_chameleon:
+    repository: xosproject/chameleon
+    tag: 'latest'
+  node:
+    repository: node
+    tag: 'latest'
+  redis:
+    repository: redis
+    tag: 'latest'
+  xos_ws:
+    repository: xosproject/xos-ws
+    tag: 'latest'
+
+# synchronizers:
+#   - name: vsg
+#     repository: xosprogect/vsg-synchronizer
+#     tag: 'latest'
+
+secrets:
+  im_cert_chain: <BASE64_ENCODED_PEM_DATA>
+  core_api_cert: <BASE64_ENCODED_PEM_DATA>
+  core_api_key: <BASE64_ENCODED_PEM_DATA>
+
+configs:
+  initial_data_config: <INITIAL_DATA>
+  core_config: <CORE_CONFIG_DATA>
+  gui_style_config: <STYLE_CONFIG_DATA>
+  gui_app_config: <APP_CONFIG_DATA>
+  gateway_config: <GATEWAY_CONFIG_DATA>
+  tosca_config: <TOSCA_CONFIG_DATA>
+  # |-
+  #   ---
+  #   name: xos-core
+  #   database:
+  #     name: xos
+  #     username: postgres
+  #     password: password
+  #   logging:
+  #     version: 1
+  #     handlers:
+  #       console:
+  #         class: logging.StreamHandler
+  #       file:
+  #         class: logging.handlers.RotatingFileHandler
+  #         filename: /var/log/xos.log
+  #         maxBytes: 10485760
+  #         backupCount: 5
+  #     loggers:
+  #       '':
+  #         handlers:
+  #             - console
+  #             - file
+  #         level: DEBUG
+  #   xos_dir: /opt/xos