Loading manifests/webuiservice.yaml +29 −27 Original line number Diff line number Diff line Loading @@ -17,20 +17,22 @@ spec: image: registry.gitlab.com/teraflow-h2020/controller/webui:latest imagePullPolicy: Always ports: - containerPort: 8001 # TODO: define the real port - containerPort: 8004 # TODO: define the real port env: - name: DB_ENGINE value: "redis" - name: REDIS_DATABASE_ID value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10000"] httpGet: path: /healthz/ready port: 8004 initialDelaySeconds: 5 timeoutSeconds: 1 livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10000"] httpGet: path: /healthz/live port: 8004 initialDelaySeconds: 5 timeoutSeconds: 1 resources: requests: cpu: 250m Loading @@ -48,23 +50,23 @@ spec: selector: app: webuiservice ports: - name: grpc port: 10000 targetPort: 10000 - name: http port: 8004 targetPort: 8004 --- apiVersion: v1 kind: Service metadata: name: webuiservice-public labels: app: webuiservice spec: type: NodePort selector: app: webuiservice ports: - name: grpc protocol: TCP port: 10000 targetPort: 10000 # apiVersion: v1 # kind: Service # metadata: # name: webuiservice-public # labels: # app: webuiservice # spec: # type: NodePort # selector: # app: webuiservice # ports: # - name: http # protocol: TCP # port: 8004 # targetPort: 8004 --- src/device/client/DeviceClient.py +1 −9 Original line number Diff line number Diff line import grpc, logging from common.tools.client.RetryDecorator import retry, delay_exponential from device.proto.context_pb2 import Device, DeviceId, Empty from device.proto.device_pb2 import MonitoringSettings from device.proto.device_pb2_grpc import DeviceServiceStub LOGGER = logging.getLogger(__name__) Loading @@ -22,7 +21,7 @@ class DeviceClient: self.stub = DeviceServiceStub(self.channel) def close(self): if self.channel is not None: self.channel.close() if(self.channel is not None): self.channel.close() self.channel = None self.stub = None Loading @@ -46,10 +45,3 @@ class DeviceClient: response = self.stub.DeleteDevice(request) LOGGER.debug('DeleteDevice result: {:s}'.format(str(response))) return response @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') def MonitorDeviceKpi(self, request: MonitoringSettings) -> Empty: LOGGER.debug('MonitorDeviceKpi request: {:s}'.format(str(request))) response = self.stub.MonitorDeviceKpi(request) LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(str(response))) return response src/device/proto/monitoring_pb2.py +228 −63 File changed.Preview size limit exceeded, changes collapsed. Show changes src/webui/.gitlab-ci.yml +2 −2 Original line number Diff line number Diff line # build, tag and push the Docker image to the gitlab registry build webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME: 'webuiwervice' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: build before_script: Loading @@ -26,7 +26,7 @@ build webui: # apply unit test to the webui component unit test webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME: 'webuiwervice' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: Loading src/webui/service/__init__.py +29 −0 Original line number Diff line number Diff line import os from flask import Flask, session from flask_healthz import healthz, HealthError from device.client.DeviceClient import DeviceClient from context.client.ContextClient import ContextClient from webui.Config import (CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT, DEVICE_SERVICE_ADDRESS, DEVICE_SERVICE_PORT) def get_working_context() -> str: Loading @@ -9,11 +15,34 @@ def get_working_context() -> str: return 'Not selected' def liveness(): pass def readiness(): try: # this component is ready when it is able to connect with the other components it depends on context_client: ContextClient = ContextClient(CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT) context_client.connect() context_client.close() device_client: DeviceClient = DeviceClient(DEVICE_SERVICE_ADDRESS, DEVICE_SERVICE_PORT) device_client.connect() device_client.close() except Exception as e: raise HealthError('Can\'t connect with the service: ' + e.details()) def create_app(use_config=None): app = Flask(__name__) if use_config: app.config.from_mapping(**use_config) app.config.update(HEALTHZ={ 'live': liveness, 'ready': readiness }) app.register_blueprint(healthz, url_prefix='/healthz') from webui.service.main.routes import main app.register_blueprint(main) Loading Loading
manifests/webuiservice.yaml +29 −27 Original line number Diff line number Diff line Loading @@ -17,20 +17,22 @@ spec: image: registry.gitlab.com/teraflow-h2020/controller/webui:latest imagePullPolicy: Always ports: - containerPort: 8001 # TODO: define the real port - containerPort: 8004 # TODO: define the real port env: - name: DB_ENGINE value: "redis" - name: REDIS_DATABASE_ID value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10000"] httpGet: path: /healthz/ready port: 8004 initialDelaySeconds: 5 timeoutSeconds: 1 livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10000"] httpGet: path: /healthz/live port: 8004 initialDelaySeconds: 5 timeoutSeconds: 1 resources: requests: cpu: 250m Loading @@ -48,23 +50,23 @@ spec: selector: app: webuiservice ports: - name: grpc port: 10000 targetPort: 10000 - name: http port: 8004 targetPort: 8004 --- apiVersion: v1 kind: Service metadata: name: webuiservice-public labels: app: webuiservice spec: type: NodePort selector: app: webuiservice ports: - name: grpc protocol: TCP port: 10000 targetPort: 10000 # apiVersion: v1 # kind: Service # metadata: # name: webuiservice-public # labels: # app: webuiservice # spec: # type: NodePort # selector: # app: webuiservice # ports: # - name: http # protocol: TCP # port: 8004 # targetPort: 8004 ---
src/device/client/DeviceClient.py +1 −9 Original line number Diff line number Diff line import grpc, logging from common.tools.client.RetryDecorator import retry, delay_exponential from device.proto.context_pb2 import Device, DeviceId, Empty from device.proto.device_pb2 import MonitoringSettings from device.proto.device_pb2_grpc import DeviceServiceStub LOGGER = logging.getLogger(__name__) Loading @@ -22,7 +21,7 @@ class DeviceClient: self.stub = DeviceServiceStub(self.channel) def close(self): if self.channel is not None: self.channel.close() if(self.channel is not None): self.channel.close() self.channel = None self.stub = None Loading @@ -46,10 +45,3 @@ class DeviceClient: response = self.stub.DeleteDevice(request) LOGGER.debug('DeleteDevice result: {:s}'.format(str(response))) return response @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') def MonitorDeviceKpi(self, request: MonitoringSettings) -> Empty: LOGGER.debug('MonitorDeviceKpi request: {:s}'.format(str(request))) response = self.stub.MonitorDeviceKpi(request) LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(str(response))) return response
src/device/proto/monitoring_pb2.py +228 −63 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/webui/.gitlab-ci.yml +2 −2 Original line number Diff line number Diff line # build, tag and push the Docker image to the gitlab registry build webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME: 'webuiwervice' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: build before_script: Loading @@ -26,7 +26,7 @@ build webui: # apply unit test to the webui component unit test webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME: 'webuiwervice' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: Loading
src/webui/service/__init__.py +29 −0 Original line number Diff line number Diff line import os from flask import Flask, session from flask_healthz import healthz, HealthError from device.client.DeviceClient import DeviceClient from context.client.ContextClient import ContextClient from webui.Config import (CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT, DEVICE_SERVICE_ADDRESS, DEVICE_SERVICE_PORT) def get_working_context() -> str: Loading @@ -9,11 +15,34 @@ def get_working_context() -> str: return 'Not selected' def liveness(): pass def readiness(): try: # this component is ready when it is able to connect with the other components it depends on context_client: ContextClient = ContextClient(CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT) context_client.connect() context_client.close() device_client: DeviceClient = DeviceClient(DEVICE_SERVICE_ADDRESS, DEVICE_SERVICE_PORT) device_client.connect() device_client.close() except Exception as e: raise HealthError('Can\'t connect with the service: ' + e.details()) def create_app(use_config=None): app = Flask(__name__) if use_config: app.config.from_mapping(**use_config) app.config.update(HEALTHZ={ 'live': liveness, 'ready': readiness }) app.register_blueprint(healthz, url_prefix='/healthz') from webui.service.main.routes import main app.register_blueprint(main) Loading