From 09fbdb4c171e1e2fae97c2bfaf7038a3ebca18a1 Mon Sep 17 00:00:00 2001
From: Bernhard Mallinger <bernhard.mallinger@eox.at>
Date: Wed, 7 Oct 2020 18:15:14 +0200
Subject: [PATCH] Add client deployment to chart

---
 chart/files/index.html                 | 475 +++++++++++++++++++++++++
 chart/templates/client-configmap.yaml  |   6 +
 chart/templates/client-deployment.yaml |  62 ++++
 chart/templates/client-service.yaml    |  17 +
 chart/values.yaml                      |  11 +
 5 files changed, 571 insertions(+)
 create mode 100644 chart/files/index.html
 create mode 100644 chart/templates/client-configmap.yaml
 create mode 100644 chart/templates/client-deployment.yaml
 create mode 100644 chart/templates/client-service.yaml

diff --git a/chart/files/index.html b/chart/files/index.html
new file mode 100644
index 00000000..23b59e21
--- /dev/null
+++ b/chart/files/index.html
@@ -0,0 +1,475 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<meta charset="UTF-8">
+<title>PRISM View Server</title>
+<link rel="icon" href="//eox.at/wp-content/uploads/2015/06/cropped-eox_eye-192x192.png" sizes="192x192" />
+<link rel="apple-touch-icon-precomposed" href="//eox.at/wp-content/uploads/2015/06/cropped-eox_eye-180x180.png" />
+</head>
+<body>
+<header id="header" style="width: 100%; height:70px;">
+    <h3 style="width:100%;text-align:center;
+    color: #006699;">PRISM View Server (PVS) Client powered by
+    <a href="//eox.at"><img src="//eox.at/wp-content/uploads/2017/09/EOX_Logo.svg" alt="EOX" style="height:25px;margin-left:10px"/></a>
+    </h3>
+</header>
+<div id="app" style="width: 100%; top: 60px; bottom: 0; position: absolute; margin: 0; padding:0;"></div>
+<script src="prism.js"></script>
+<script>
+var baseUrl = '//vhr18-dev.vs.hub.eox.at/';
+var baseUrlsWMTS = [
+    '//vhr18-dev.vs.hub.eox.at/cache/ows/wmts',
+];
+var baseUrlsOws = [
+    '//vhr18-dev.vs.hub.eox.at/ows',
+];
+var config = {
+    "settings": {
+        "rightPanelOpen": true,
+        "leftPanelOpen": false,
+        "leftPanelTabIndex": 0,
+        "tutorial": "once",
+        "uploadEnabled": true,
+        "selectFilesDownloadEnabled": false,
+        "downloadEnabled": true,
+        "searchEnabled" : true,
+        "searchDebounceTime": 500,
+        "language": "en",
+        "timeDomain": [
+            "2017-01-01T00:00:00Z",
+            "2019-12-31T23:59:59Z",
+        ],
+        "constrainTimeDomain": true,
+        "displayTimeDomain": [
+            "2017-01-01T00:00:00Z",
+            "2019-12-31T23:59:59Z",
+        ],
+        "displayInterval": "P1096D",
+        "selectedTimeDomain": [
+            "2018-08-01T00:00:00Z",
+            "2018-08-31T23:59:59Z",
+        ],
+        "selectableInterval": "P1096D",
+        "timeSliderControls": true,
+        "maxTooltips": 1,
+        "center": [12, 49],
+        "zoom": 5,
+        "maxZoom": 17,
+        "footprintFillColor": "rgba(0, 0, 0, 0.2)",
+        "footprintStrokeColor": "rgba(0, 0, 0, 1)",
+        "filterFillColor": "rgba(0, 165, 255, 0)",
+        "filterStrokeColor": "rgba(0, 165, 255, 1)",
+        "filterOutsideColor": "rgba(0, 0, 0, 0.5)",
+        "selectedFootprintFillColor": "rgba(255, 0, 0, 0.2)",
+        "selectedFootprintStrokeColor": "rgba(255, 0, 0, 1)",
+        "highlightFillColor": "rgba(246, 182, 0, 0.5)",
+        "highlightStrokeColor": "rgba(246, 182, 0, 1)",
+        "highlightStrokeWidth": 3,
+        "translations": {
+            "en": {
+                "Cloud Cover": "Cloud coverage (%)",
+                "Error: NoApplicableCode": "Search timed out. Please refine the filter criteria.",
+            }
+        },
+        "filterSettings": {
+            "time": {
+                "hidden": true,
+            }
+        },
+        "downloadFormats": [
+            {
+                "name": "TIFF",
+                "mimeType": "image/tiff"
+            },
+            {
+                "name": "JPEG 2000",
+                "mimeType": "image/jp2"
+            },
+            {
+                "name": "HDF",
+                "mimeType": "application/x-hdf",
+            },
+        ],
+        "downloadProjections": [
+            {
+                "name": "WGS-84",
+                "identifier": "http://www.opengis.net/def/crs/EPSG/0/4326"
+            },
+            {
+                "name": "Web Mercator",
+                "identifier": "http://www.opengis.net/def/crs/EPSG/0/3857"
+            },
+            {
+                "name": "ETRS89 / LAEA Europe",
+                "identifier": "http://www.opengis.net/def/crs/EPSG/0/3035"
+            }
+        ],
+        "downloadInterpolations": [
+            {
+            "name": "Bilinear",
+            "identifier": "http://www.opengis.net/def/interpolation/OGC/1/bilinear"
+            },
+            {
+                "name": "Nearest Neighbour",
+                "identifier": "http://www.opengis.net/def/interpolation/OGC/1/nearest-neighbour"
+            },
+            {
+                "name": "Average",
+                "identifier": "http://www.opengis.net/def/interpolation/OGC/1/average"
+            },
+        ]
+    },
+    "baseLayers": [
+        {
+            "id": "terrain-light",
+            "displayName": "EOX Terrain-Light",
+            "display": {
+                "id": "terrain-light",
+                "visible": true,
+                "protocol": "WMTS",
+                "urls": [
+                    "//a.s2maps-tiles.eu/wmts/",
+                    "//b.s2maps-tiles.eu/wmts/",
+                    "//c.s2maps-tiles.eu/wmts/",
+                    "//d.s2maps-tiles.eu/wmts/",
+                    "//e.s2maps-tiles.eu/wmts/",
+                ],
+                "matrixSet": "WGS84",
+                "format": "image/png",
+                "projection": "EPSG:4326",
+                "style": "default",
+                "attribution": "Terrain-Light { Data &copy; <a href=\"//www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors and <a href='javascript:;' onClick='toggle(terrain_attribution)'>others</a>, Rendering &copy; <a href=\"//eox.at\" target=\"_blank\">EOX</a> }"
+            }
+        }, {
+            "id": "terrain",
+            "displayName": "EOX Terrain",
+            "display": {
+                "id": "terrain",
+                "visible": false,
+                "protocol": "WMTS",
+                "urls": [
+                    "//a.s2maps-tiles.eu/wmts/",
+                    "//b.s2maps-tiles.eu/wmts/",
+                    "//c.s2maps-tiles.eu/wmts/",
+                    "//d.s2maps-tiles.eu/wmts/",
+                    "//e.s2maps-tiles.eu/wmts/"
+                ],
+                "matrixSet": "WGS84",
+                "format": "image/png",
+                "projection": "EPSG:4326",
+                "style": "default",
+                "attribution": "Terrain { Data &copy; <a href=\"//www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors and <a href='javascript:;' onClick='toggle(terrain_attribution)'>others</a>, Rendering &copy; <a href=\"//eox.at\" target=\"_blank\">EOX</a> }"
+            }
+        },  {
+            "id": "s2cloudless",
+            "displayName": "EOX Sentinel-2 cloudless",
+            "display": {
+                "id": "s2cloudless-2018",
+                "visible": false,
+                "protocol": "WMTS",
+                "urls": [
+                    "//a.s2maps-tiles.eu/wmts/",
+                    "//b.s2maps-tiles.eu/wmts/",
+                    "//c.s2maps-tiles.eu/wmts/",
+                    "//d.s2maps-tiles.eu/wmts/",
+                    "//e.s2maps-tiles.eu/wmts/"
+                ],
+                "matrixSet": "WGS84",
+                "format": "image/png",
+                "projection": "EPSG:4326",
+                "style": "default",
+                "attribution": "<a xmlns:dct=\"//purl.org/dc/terms/\" href=\"//s2maps.eu\" property=\"dct:title\">Sentinel-2 cloudless - //s2maps.eu</a> by <a xmlns:cc=\"//creativecommons.org/ns#\" href=\"s://eox.at\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">EOX IT Services GmbH</a> (Contains modified Copernicus Sentinel data 2017 &amp; 2018)"
+            }
+        }
+    ],
+    "layers": [
+        {
+            "id": 'VHR_IMAGE_2018_Level_1',
+            "displayName": 'VHR Image 2018 Level 1',
+            "displayColor": '#eb3700',
+            "display": {
+                "id": 'VHR_IMAGE_2018_Level_1__TRUE_COLOR',
+                "visible": false,
+                "protocol": 'WMTS',
+                "urls": baseUrlsWMTS,
+                "format": 'image/png',
+                "projection": 'EPSG:4326',
+                "matrixSet": "WGS84",
+                "style": 'default',
+                "useMilliseconds": false,
+                "maxZoom": 17,
+                "options": [{
+                    "name": "Style",
+                    "target": "display.extraParameters.LAYERS",
+                    "values": [{
+                    "label": "VHR Image 2018 True Color",
+                    "value": "VHR_IMAGE_2018_Level_1__TRUE_COLOR",
+                    }, {
+                    "label": "VHR Image 2018 True Color with masked validity",
+                    "value": "VHR_IMAGE_2018_Level_1__masked_validity",
+                    }, {
+                    "label": "VHR Image 2018 False Color",
+                    "value": "VHR_IMAGE_2018_Level_1__FALSE_COLOR",
+                    }, {
+                    "label": "VHR Image 2018 NDVI",
+                    "value": "VHR_IMAGE_2018_Level_1__NDVI",
+                    }]
+                }],
+            },
+            "search": {
+                "protocol": "OpenSearch",
+                "url": baseUrl + "opensearch/collections/VHR_IMAGE_2018_Level_1/",
+                "id": "VHR_IMAGE_2018_Level_1",
+                "histogramBinCount": 28,
+                "format": "application/atom+xml",
+                "method": "GET",
+                "histogramThreshold": 600,
+                "lightweightBuckets": true,
+                "searchLimit": 600,
+                "loadMore": 600,
+                "pageSize": 200,
+                "countZeroRecords": true,
+                "parameters": [
+                    {
+                        "type": "eo:sensorMode",
+                        "name": "Sensor",
+                        "title": "Sensor Mode"
+                    },
+                    {
+                        "max": 100,
+                        "min": 0,
+                        "step": 1,
+                        "range": true,
+                        "type": "eo:cloudCover",
+                        "name": "Cloud Coverage",
+                        "title": "Cloud Coverage in percent"
+                    },
+                    {
+                        "max": 360,
+                        "min": 0,
+                        "step": 1,
+                        "range": true,
+                        "type": "eo:acrossTrackIncidenceAngle",
+                        "name": "Offnadir angle",
+                        "title": "Across Track Incidence Angle in degrees"
+                    },
+                    {
+                        "max": 360,
+                        "min": 0,
+                        "step": 1,
+                        "range": true,
+                        "type": "eo:illuminationAzimuthAngle",
+                        "name": "Sun elevation",
+                        "title": "Illumination Azimuth Angle in degrees"
+                    },
+                ],
+                "parametersFilterSettings": {
+                    "collapsed": false,
+                },
+            },
+            "download": {
+                "protocol": "EO-WCS",
+                "url": baseUrl + "ows",
+                // "method": "GET",
+                "rewrite": {
+                // add __coverage to the coverageId
+                "from": "({{id}})",
+                "to": "$1__coverage"
+                }
+            }
+        },
+        {
+            "id": 'VHR_IMAGE_2018_Level_3',
+            "displayName": 'VHR Image 2018 Level 3',
+            "displayColor": '#37eb00',
+            "display": {
+                "id": 'VHR_IMAGE_2018_Level_3__TRUE_COLOR',
+                "visible": true,
+                "protocol": 'WMTS',
+                "urls": baseUrlsWMTS,
+                "format": 'image/png',
+                "projection": 'EPSG:4326',
+                "matrixSet": "WGS84",
+                "style": 'default',
+                "useMilliseconds": false,
+                "maxZoom": 17,
+                "options": [{
+                    "name": "Style",
+                    "target": "display.extraParameters.LAYERS",
+                    "values": [{
+                    "label": "VHR Image 2018 True Color",
+                    "value": "VHR_IMAGE_2018_Level_3__TRUE_COLOR",
+                    }, {
+                    "label": "VHR Image 2018 True Color with masked validity",
+                    "value": "VHR_IMAGE_2018_Level_3__masked_validity",
+                    }, {
+                    "label": "VHR Image 2018 False Color",
+                    "value": "VHR_IMAGE_2018_Level_3__FALSE_COLOR",
+                    }, {
+                    "label": "VHR Image 2018 NDVI",
+                    "value": "VHR_IMAGE_2018_Level_3__NDVI",
+                    }]
+                }],
+            },
+            "search": {
+                "protocol": "OpenSearch",
+                "url": baseUrl + "opensearch/collections/VHR_IMAGE_2018_Level_3/",
+                "id": "VHR_IMAGE_2018_Level_3",
+                "histogramBinCount": 28,
+                "format": "application/atom+xml",
+                "method": "GET",
+                "histogramThreshold": 600,
+                "lightweightBuckets": true,
+                "searchLimit": 600,
+                "loadMore": 600,
+                "pageSize": 200,
+                "countZeroRecords": true,
+                "parameters": [
+                    {
+                        "type": "eo:sensorMode",
+                        "name": "Sensor",
+                        "title": "Sensor Mode"
+                    },
+                    {
+                        "max": 100,
+                        "min": 0,
+                        "step": 1,
+                        "range": true,
+                        "type": "eo:cloudCover",
+                        "name": "Cloud Coverage",
+                        "title": "Cloud Coverage in percent"
+                    },
+                    {
+                        "max": 360,
+                        "min": 0,
+                        "step": 1,
+                        "range": true,
+                        "type": "eo:acrossTrackIncidenceAngle",
+                        "name": "Offnadir angle",
+                        "title": "Across Track Incidence Angle in degrees"
+                    },
+                    {
+                        "max": 360,
+                        "min": 0,
+                        "step": 1,
+                        "range": true,
+                        "type": "eo:illuminationAzimuthAngle",
+                        "name": "Sun elevation",
+                        "title": "Illumination Azimuth Angle in degrees"
+                    },
+                ],
+                "parametersFilterSettings": {
+                    "collapsed": false,
+                },
+            },
+            "download": {
+                "protocol": "EO-WCS",
+                "url": baseUrl + "ows",
+                // "method": "GET",
+                "rewrite": {
+                // add __coverage to the coverageId
+                "from": "({{id}})",
+                "to": "$1__coverage"
+                }
+            }
+        },
+    ],
+    "overlayLayers": [
+        {
+            "id": "overlay_base",
+            "displayName": "EOX Borders and Labels",
+            "display": {
+                "id": "overlay_base",
+                "visible": false,
+                "protocol": "WMTS",
+                "urls": [
+                    "//a.s2maps-tiles.eu/wmts/",
+                    "//b.s2maps-tiles.eu/wmts/",
+                    "//c.s2maps-tiles.eu/wmts/",
+                    "//d.s2maps-tiles.eu/wmts/",
+                    "//e.s2maps-tiles.eu/wmts/"
+                ],
+                "matrixSet": "WGS84",
+                "style": "default",
+                "format": "image/png",
+                "projection": "EPSG:4326",
+                "attribution": "Overlay { Data &copy; <a href=\"//www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors, Rendering &copy; <a href=\"//eox.at\" target=\"_blank\">EOX</a> and <a href=\"//github.com/mapserver/basemaps\" target=\"_blank\">MapServer</a> }"
+            }
+        },
+        {
+            "id": 'VHR_IMAGE_2018_Level_3__outlines',
+            "displayName": 'VHR Image 2018 Level 3 Outlines',
+            "displayColor": '#187465',
+            "display": {
+                "id": 'VHR_IMAGE_2018_Level_3__outlines',
+                "visible": false,
+                "protocol": 'WMS',
+                "urls": baseUrlsOws,
+                "format": 'image/png',
+                "projection": 'EPSG:4326',
+                "style": 'red',
+                "useMilliseconds": false,
+                "maxZoom": 17,
+                "synchronizeTime": true,
+            },
+        },
+        {
+            "id": 'VHR_IMAGE_2018_Level_3__masked_validity__Full',
+            "displayName": 'VHR Image 2018 Level 3 True Color with masked validity Full Coverage',
+            "display": {
+                "id": 'VHR_IMAGE_2018_Level_3__masked_validity__Full',
+                "visible": false,
+                "protocol": 'WMTS',
+                "urls": baseUrlsWMTS,
+                "format": 'image/png',
+                "projection": 'EPSG:4326',
+                "matrixSet": "WGS84",
+                "maxZoom": 17,
+                "synchronizeTime": false,
+                "style": "default",
+            },
+        },
+        {
+            "id": 'VHR_IMAGE_2018_Level_3__Full',
+            "displayName": 'VHR Image 2018 Level 3 True Color Full Coverage',
+            "display": {
+                "id": 'VHR_IMAGE_2018_Level_3__Full',
+                "visible": false,
+                "protocol": 'WMTS',
+                "urls": baseUrlsWMTS,
+                "format": 'image/png',
+                "projection": 'EPSG:4326',
+                "matrixSet": "WGS84",
+                "maxZoom": 17,
+                "synchronizeTime": false,
+                "style": "default",
+            },
+        },
+        {
+            "id": 'VHR_IMAGE_2018_Level_3__FALSE_COLOR__Full',
+            "displayName": 'VHR Image 2018 Level 3 False Color Full Coverage',
+            "display": {
+                "id": 'VHR_IMAGE_2018_Level_3__FALSE_COLOR__Full',
+                "visible": false,
+                "protocol": 'WMTS',
+                "urls": baseUrlsWMTS,
+                "format": 'image/png',
+                "projection": 'EPSG:4326',
+                "matrixSet": "WGS84",
+                "maxZoom": 17,
+                "synchronizeTime": false,
+                "style": "default",
+            },
+        }
+    ]
+};
+
+    var app = new Application({
+    config: config,
+    container: document.getElementById('app'),
+    });
+    app.start();
+</script>
+</body>
+</html>
diff --git a/chart/templates/client-configmap.yaml b/chart/templates/client-configmap.yaml
new file mode 100644
index 00000000..4b130f7e
--- /dev/null
+++ b/chart/templates/client-configmap.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "vs.fullname" . }}-client
+data:
+  {{ (.Files.Glob "files/index.html").AsConfig | nindent 2}}
diff --git a/chart/templates/client-deployment.yaml b/chart/templates/client-deployment.yaml
new file mode 100644
index 00000000..31e8ebd6
--- /dev/null
+++ b/chart/templates/client-deployment.yaml
@@ -0,0 +1,62 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name: {{ include "vs.fullname" . }}-client
+  labels:
+    {{- include "vs.labels" . | nindent 4 }}
+    app.kubernetes.io/service: client
+spec:
+  replicas: {{ .Values.client.replicaCount }}
+  selector:
+    matchLabels:
+      {{- include "vs.selectorLabels" . | nindent 6 }}
+      app.kubernetes.io/service: client
+  strategy:
+    rollingUpdate:
+      maxUnavailable: 0
+    type: RollingUpdate
+  template:
+    metadata:
+      annotations:
+        prometheus.io/scrape: "false"
+      labels:
+        {{- include "vs.selectorLabels" . | nindent 8 }}
+        app.kubernetes.io/service: client
+    spec:
+      {{- with .Values.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      containers:
+        - name: {{ .Chart.Name }}-client
+          image: 'registry.gitlab.eox.at/esa/prism/vs/pvs_client:{{ .Values.image.tag | default .Chart.AppVersion }}'
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          ports:
+            - name: http
+              containerPort: 80
+              protocol: TCP
+          livenessProbe:
+            httpGet:
+              path: /
+              port: http
+          readinessProbe:
+            httpGet:
+              path: /
+              port: http
+          resources:
+            {{- toYaml .Values.client.resources | nindent 12 }}
+          volumeMounts:
+          - mountPath: /usr/share/nginx/html/index.html
+            name: client
+            subPath: index.html
+      {{- with .Values.client.affinity | default .Values.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      volumes:
+      - configMap:
+          items:
+          - key: index.html
+            path: index.html
+          name: {{ include "vs.fullname" . }}-client
+        name: client
diff --git a/chart/templates/client-service.yaml b/chart/templates/client-service.yaml
new file mode 100644
index 00000000..587cba40
--- /dev/null
+++ b/chart/templates/client-service.yaml
@@ -0,0 +1,17 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ include "vs.fullname" . }}-client
+  labels:
+    {{- include "vs.labels" . | nindent 4 }}
+    app.kubernetes.io/service: client
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    - port: {{ .Values.service.port }}
+      targetPort: http
+      protocol: TCP
+      name: http
+  selector:
+    {{- include "vs.selectorLabels" . | nindent 4 }}
+    app.kubernetes.io/service: client
diff --git a/chart/values.yaml b/chart/values.yaml
index adfec900..a779f6ca 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -79,6 +79,17 @@ renderer:
       memory: 2Gi
   affinity: {}
 
+client:
+  replicaCount: 1
+  resources:
+    limits:
+      cpu: 0.5
+      memory: 1Gi
+    requests:
+      cpu: 0.1
+      memory: 0.1Gi
+
+
 replicaCount: 1
 
 image:
-- 
GitLab