From f6019f43e24b26fab08cdc958e11dc6dd9f943fc Mon Sep 17 00:00:00 2001 From: Markus Holtermann Date: Thu, 22 Oct 2020 14:13:18 +0200 Subject: [PATCH] Fix deployment --- .../examples/grafana_demo_live/.gitignore | 1 + .../examples/grafana_demo_live/README.md | 10 + .../grafana_demo_live/grafana_config_map.yml | 7 +- .../grafana_demo_live/grafana_demo_model.json | 138 ------------- .../k8s_deploy_grafana_demo_data.yml | 189 +++++++++++++++++- 5 files changed, 195 insertions(+), 150 deletions(-) create mode 100644 src/data_generator/examples/grafana_demo_live/.gitignore create mode 100644 src/data_generator/examples/grafana_demo_live/README.md delete mode 100644 src/data_generator/examples/grafana_demo_live/grafana_demo_model.json diff --git a/src/data_generator/examples/grafana_demo_live/.gitignore b/src/data_generator/examples/grafana_demo_live/.gitignore new file mode 100644 index 0000000..10fd06c --- /dev/null +++ b/src/data_generator/examples/grafana_demo_live/.gitignore @@ -0,0 +1 @@ +manifest.yaml diff --git a/src/data_generator/examples/grafana_demo_live/README.md b/src/data_generator/examples/grafana_demo_live/README.md new file mode 100644 index 0000000..3c3c1f9 --- /dev/null +++ b/src/data_generator/examples/grafana_demo_live/README.md @@ -0,0 +1,10 @@ +# Deployment + +In order for K8s to access the data generator Docker image, the `image-pull-cr8` secret is needed. This is replicated from the `templates` namespace. + +The data generator uses the `admin` user and access the corresponding password from the K8s secret. + +```console +$ j2cli -c grafana_config_map.yml k8s_deploy_grafana_demo_data.yml > manifest.yaml +$ kubectl --context k8s.westeurope.azure apply -f manifest.yaml +``` diff --git a/src/data_generator/examples/grafana_demo_live/grafana_config_map.yml b/src/data_generator/examples/grafana_demo_live/grafana_config_map.yml index 05d058c..c2b164f 100644 --- a/src/data_generator/examples/grafana_demo_live/grafana_config_map.yml +++ b/src/data_generator/examples/grafana_demo_live/grafana_config_map.yml @@ -1,10 +1,15 @@ kubernetes: name: grafana-demo-data + namespace: 00768a8e-14ea-4daa-bc38-592bf1486d85 -version: latest +version: v0.1.2 ID_START: 1 ID_END: 150 db: crateuri: https://grafana-demo-1.westeurope.azure.cratedb.net:4200 + +credentials: + username: admin + password_k8s_secret: user-password-35e75e5f-5308-4e98-999d-2be9d2fa47af-0 diff --git a/src/data_generator/examples/grafana_demo_live/grafana_demo_model.json b/src/data_generator/examples/grafana_demo_live/grafana_demo_model.json deleted file mode 100644 index 48a82c6..0000000 --- a/src/data_generator/examples/grafana_demo_live/grafana_demo_model.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "grafana_demo_values": { - "tags": { - "factory": 2, - "machine": 10, - "sensor": "id" - }, - "metrics": { - "temperature": { - "key": { - "value": "temperature" - }, - "type": { - "value": "FLOAT" - }, - "min": { - "value": 50 - }, - "max": { - "value": 200 - }, - "mean": { - "value": 125 - }, - "stdev": { - "value": 5 - }, - "variance": { - "value": 0.5 - }, - "error_rate": { - "value": 0.00001 - }, - "error_length": { - "value": 2.07 - } - }, - "fluid_level": { - "key": { - "value": "fluid_level" - }, - "type": { - "value": "FLOAT" - }, - "min": { - "value": 85 - }, - "max": { - "value": 100 - }, - "mean": { - "value": 92 - }, - "stdev": { - "value": 1 - }, - "variance": { - "value": 0.01 - }, - "error_rate": { - "value": 0.0001 - }, - "error_length": { - "value": 2.07 - } - }, - "humidity": { - "key": { - "value": "humidity" - }, - "type": { - "value": "FLOAT" - }, - "min": { - "value": 30 - }, - "max": { - "value": 60 - }, - "mean": { - "value": 45 - }, - "stdev": { - "value": 1 - }, - "variance": { - "value": 0.01 - }, - "error_rate": { - "value": 0.0001 - }, - "error_length": { - "value": 2.07 - } - }, - "pressure": { - "key": { - "value": "pressure" - }, - "type": { - "value": "FLOAT" - }, - "min": { - "value": 0 - }, - "max": { - "value": 50 - }, - "mean": { - "value": 37 - }, - "stdev": { - "value": 1 - }, - "variance": { - "value": 0.01 - }, - "error_rate": { - "value": 0.0001 - }, - "error_length": { - "value": 5 - } - }, - "broken": { - "key": { - "value": "broken" - }, - "type": { - "value": "BOOL" - }, - "true_ratio": { - "value": 0.01 - } - } - } - } -} diff --git a/src/data_generator/examples/grafana_demo_live/k8s_deploy_grafana_demo_data.yml b/src/data_generator/examples/grafana_demo_live/k8s_deploy_grafana_demo_data.yml index 4775335..afd4bc2 100644 --- a/src/data_generator/examples/grafana_demo_live/k8s_deploy_grafana_demo_data.yml +++ b/src/data_generator/examples/grafana_demo_live/k8s_deploy_grafana_demo_data.yml @@ -1,10 +1,177 @@ +--- +kind: ConfigMap +apiVersion: v1 +metadata: + labels: + k8s-app: datagenerator + app.kubernetes.io/name: "{{ kubernetes.name }}" + name: "datamodel" + namespace: "{{ kubernetes.namespace }}" +data: + grafana_demo_model.json: | + { + "grafana_demo_values": { + "tags": { + "factory": 2, + "machine": 10, + "sensor": "id" + }, + "metrics": { + "temperature": { + "key": { + "value": "temperature" + }, + "type": { + "value": "FLOAT" + }, + "min": { + "value": 50 + }, + "max": { + "value": 200 + }, + "mean": { + "value": 125 + }, + "stdev": { + "value": 5 + }, + "variance": { + "value": 0.5 + }, + "error_rate": { + "value": 0.00001 + }, + "error_length": { + "value": 2.07 + } + }, + "fluid_level": { + "key": { + "value": "fluid_level" + }, + "type": { + "value": "FLOAT" + }, + "min": { + "value": 85 + }, + "max": { + "value": 100 + }, + "mean": { + "value": 92 + }, + "stdev": { + "value": 1 + }, + "variance": { + "value": 0.01 + }, + "error_rate": { + "value": 0.0001 + }, + "error_length": { + "value": 2.07 + } + }, + "humidity": { + "key": { + "value": "humidity" + }, + "type": { + "value": "FLOAT" + }, + "min": { + "value": 30 + }, + "max": { + "value": 60 + }, + "mean": { + "value": 45 + }, + "stdev": { + "value": 1 + }, + "variance": { + "value": 0.01 + }, + "error_rate": { + "value": 0.0001 + }, + "error_length": { + "value": 2.07 + } + }, + "pressure": { + "key": { + "value": "pressure" + }, + "type": { + "value": "FLOAT" + }, + "min": { + "value": 0 + }, + "max": { + "value": 50 + }, + "mean": { + "value": 37 + }, + "stdev": { + "value": 1 + }, + "variance": { + "value": 0.01 + }, + "error_rate": { + "value": 0.0001 + }, + "error_length": { + "value": 5 + } + }, + "broken": { + "key": { + "value": "broken" + }, + "type": { + "value": "BOOL" + }, + "true_ratio": { + "value": 0.01 + } + } + } + } + } + +--- +apiVersion: v1 +kind: Secret +metadata: + name: image-pull-cr8 + namespace: "{{ kubernetes.namespace }}" + labels: + app.kubernetes.io/name: image-pull-cr8 + app.kubernetes.io/part-of: cratedb + app.kubernetes.io/managed-by: replicator + annotations: + replicator.v1.mittwald.de/replicate-from: "templates/image-pull-cr8" +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: "e30K" # empty {} + +--- apiVersion: batch/v1 kind: Job metadata: labels: k8s-app: datagenerator - app.kubernetes.io/name: {{ kubernetes.name }} - name: dg-{{ ID_START }} + app.kubernetes.io/name: "{{ kubernetes.name }}" + name: "dg-{{ ID_START }}" namespace: "{{ kubernetes.namespace }}" spec: backoffLimit: 0 @@ -16,13 +183,13 @@ spec: prometheus.io/path: "/metrics" labels: k8s-app: datagenerator - app.kubernetes.io/name: {{ kubernetes.name }} + app.kubernetes.io/name: "{{ kubernetes.name }}" spec: imagePullSecrets: - name: image-pull-cr8 containers: - name: datagenerator - image: registry.cr8.net/data-generator:{{ version }} + image: "registry.cr8.net/data-generator:{{ version }}" ports: - containerPort: 8000 protocol: TCP @@ -43,7 +210,7 @@ spec: - name: ID_END value: "{{ ID_END }}" - name: HOST - value: {{ db.crateuri }} + value: "{{ db.crateuri }}" - name: INGEST_MODE value: "0" - name: INGEST_SIZE @@ -57,17 +224,17 @@ spec: - name: SHARDS value: "4" - name: USERNAME - valueFrom: - secretKeyRef: - name: datagenerator - key: crate_user + value: "{{ credentials.username }}" - name: PASSWORD valueFrom: secretKeyRef: - name: datagenerator - key: crate_password + name: "{{ credentials.password_k8s_secret }}" + key: password restartPolicy: Never volumes: - name: datamodel configMap: name: datamodel + items: + - key: grafana_demo_model.json + path: grafana_demo_model.json