From 294584d788bec84e3116ce5adac4358c9f33b64f Mon Sep 17 00:00:00 2001 From: Tobias Eidelpes Date: Thu, 17 Jun 2021 22:37:40 +0200 Subject: [PATCH] Implement SCALING with ENV variable --- components/i_feed/devices/traffic_light.py | 3 ++- components/i_feed/devices/vehicle.py | 3 ++- components/orchestration/orchestrator.py | 3 ++- kubernetes/configmaps/scaling-configmap.yaml | 2 +- kubernetes/deployments/controlcenter-deployment.yaml | 4 ++-- kubernetes/deployments/entityident-deployment.yaml | 4 ++-- kubernetes/deployments/eventstore-deployment.yaml | 4 ++-- kubernetes/deployments/ifeed-deployment.yaml | 4 ++-- kubernetes/deployments/orchestration-deployment.yaml | 4 ++-- kubernetes/deployments/xway-deployment.yaml | 4 ++-- 10 files changed, 19 insertions(+), 16 deletions(-) diff --git a/components/i_feed/devices/traffic_light.py b/components/i_feed/devices/traffic_light.py index e6f2282..b194f7a 100644 --- a/components/i_feed/devices/traffic_light.py +++ b/components/i_feed/devices/traffic_light.py @@ -1,6 +1,7 @@ import pickle import threading import time +import os from datetime import datetime from circuitbreaker import circuit @@ -13,7 +14,7 @@ from pika.exceptions import AMQPConnectionError SWITCHING_TIME = 15 # Scale speed of switching by factor x -SCALING = 6 +SCALING = int(os.environ['DSE2021_SCALING']) class TrafficLight: diff --git a/components/i_feed/devices/vehicle.py b/components/i_feed/devices/vehicle.py index 45aa7cf..3440cec 100644 --- a/components/i_feed/devices/vehicle.py +++ b/components/i_feed/devices/vehicle.py @@ -1,6 +1,7 @@ import pickle import threading import time +import os from datetime import datetime from typing import Union @@ -19,7 +20,7 @@ STARTING_POINT = geopy.Point(47.89053, 16.20703) # Driving direction in degrees: 0=N, 90=E, 180=S, 270=W BEARING = 2 # Scale speed of vehicles by factor x -SCALING = 6 +SCALING = int(os.environ['DSE2021_SCALING']) # in km/h STARTING_VELOCITY = 130 * SCALING # Interval between status updates in seconds (is not scaled) diff --git a/components/orchestration/orchestrator.py b/components/orchestration/orchestrator.py index 43fe5a9..2135582 100644 --- a/components/orchestration/orchestrator.py +++ b/components/orchestration/orchestrator.py @@ -1,6 +1,7 @@ import datetime import pickle import sys +import os from typing import List, Dict from datetime import datetime, timedelta from math import floor @@ -22,7 +23,7 @@ sys.modules['target_velocity'] = target_velocity ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/' -SCALING = 6 +SCALING = int(os.environ['DSE2021_SCALING']) class Orchestrator: diff --git a/kubernetes/configmaps/scaling-configmap.yaml b/kubernetes/configmaps/scaling-configmap.yaml index a2de7d1..43d8d92 100644 --- a/kubernetes/configmaps/scaling-configmap.yaml +++ b/kubernetes/configmaps/scaling-configmap.yaml @@ -3,4 +3,4 @@ kind: ConfigMap metadata: name: scaling-configmap data: - scaling: "1" \ No newline at end of file + DSE2021_SCALING: "2" \ No newline at end of file diff --git a/kubernetes/deployments/controlcenter-deployment.yaml b/kubernetes/deployments/controlcenter-deployment.yaml index 3ab29b4..08d81a9 100644 --- a/kubernetes/deployments/controlcenter-deployment.yaml +++ b/kubernetes/deployments/controlcenter-deployment.yaml @@ -23,11 +23,11 @@ spec: - containerPort: 80 resources: {} env: - - name: SCALING + - name: DSE2021_SCALING valueFrom: configMapKeyRef: name: scaling-configmap - key: scaling + key: DSE2021_SCALING restartPolicy: Always serviceAccountName: "" volumes: null diff --git a/kubernetes/deployments/entityident-deployment.yaml b/kubernetes/deployments/entityident-deployment.yaml index 2c894e3..f70f5b9 100644 --- a/kubernetes/deployments/entityident-deployment.yaml +++ b/kubernetes/deployments/entityident-deployment.yaml @@ -23,11 +23,11 @@ spec: - containerPort: 5002 resources: {} env: - - name: SCALING + - name: DSE2021_SCALING valueFrom: configMapKeyRef: name: scaling-configmap - key: scaling + key: DSE2021_SCALING restartPolicy: Always serviceAccountName: "" volumes: null diff --git a/kubernetes/deployments/eventstore-deployment.yaml b/kubernetes/deployments/eventstore-deployment.yaml index a38908f..1e4b285 100644 --- a/kubernetes/deployments/eventstore-deployment.yaml +++ b/kubernetes/deployments/eventstore-deployment.yaml @@ -23,11 +23,11 @@ spec: - containerPort: 5001 resources: {} env: - - name: SCALING + - name: DSE2021_SCALING valueFrom: configMapKeyRef: name: scaling-configmap - key: scaling + key: DSE2021_SCALING restartPolicy: Always serviceAccountName: "" volumes: null diff --git a/kubernetes/deployments/ifeed-deployment.yaml b/kubernetes/deployments/ifeed-deployment.yaml index 981cc7c..4226fa5 100644 --- a/kubernetes/deployments/ifeed-deployment.yaml +++ b/kubernetes/deployments/ifeed-deployment.yaml @@ -21,11 +21,11 @@ spec: name: ifeed resources: {} env: - - name: SCALING + - name: DSE2021_SCALING valueFrom: configMapKeyRef: name: scaling-configmap - key: scaling + key: DSE2021_SCALING restartPolicy: Always serviceAccountName: "" volumes: null diff --git a/kubernetes/deployments/orchestration-deployment.yaml b/kubernetes/deployments/orchestration-deployment.yaml index a71e304..a9e9e30 100644 --- a/kubernetes/deployments/orchestration-deployment.yaml +++ b/kubernetes/deployments/orchestration-deployment.yaml @@ -21,11 +21,11 @@ spec: name: orchestration resources: {} env: - - name: SCALING + - name: DSE2021_SCALING valueFrom: configMapKeyRef: name: scaling-configmap - key: scaling + key: DSE2021_SCALING restartPolicy: Always serviceAccountName: "" volumes: null diff --git a/kubernetes/deployments/xway-deployment.yaml b/kubernetes/deployments/xway-deployment.yaml index 99fed99..65b0bcb 100644 --- a/kubernetes/deployments/xway-deployment.yaml +++ b/kubernetes/deployments/xway-deployment.yaml @@ -23,11 +23,11 @@ spec: - containerPort: 5004 resources: {} env: - - name: SCALING + - name: DSE2021_SCALING valueFrom: configMapKeyRef: name: scaling-configmap - key: scaling + key: DSE2021_SCALING restartPolicy: Always serviceAccountName: "" volumes: null