From 343560cf15274c4beabe9f6a445f1e2284ef57a7 Mon Sep 17 00:00:00 2001 From: Lluis Gifre <lluis.gifre@cttc.es> Date: Thu, 5 Aug 2021 13:17:27 +0200 Subject: [PATCH] Several changes: Context service: - corrected port numbers Device service: - corrected port numbers - upgraded gitlab-ci configuration --- manifests/contextservice.yaml | 10 +++++----- manifests/deviceservice.yaml | 10 +++++----- src/context/Config.py | 13 ++++++++----- src/device/.gitlab-ci.yml | 36 +++++++++++++++++------------------ src/device/Config.py | 10 +++++----- 5 files changed, 41 insertions(+), 38 deletions(-) diff --git a/manifests/contextservice.yaml b/manifests/contextservice.yaml index b05c37b49..6675c00aa 100644 --- a/manifests/contextservice.yaml +++ b/manifests/contextservice.yaml @@ -17,7 +17,7 @@ spec: image: context_service:develop imagePullPolicy: Never ports: - - containerPort: 7070 + - containerPort: 1010 env: - name: DB_ENGINE value: "redis" @@ -27,10 +27,10 @@ spec: value: "DEBUG" readinessProbe: exec: - command: ["/bin/grpc_health_probe", "-addr=:7070"] + command: ["/bin/grpc_health_probe", "-addr=:1010"] livenessProbe: exec: - command: ["/bin/grpc_health_probe", "-addr=:7070"] + command: ["/bin/grpc_health_probe", "-addr=:1010"] resources: requests: cpu: 250m @@ -49,5 +49,5 @@ spec: app: contextservice ports: - name: grpc - port: 7070 - targetPort: 7070 + port: 1010 + targetPort: 1010 diff --git a/manifests/deviceservice.yaml b/manifests/deviceservice.yaml index f8f82b1ff..631ff0cb4 100644 --- a/manifests/deviceservice.yaml +++ b/manifests/deviceservice.yaml @@ -17,7 +17,7 @@ spec: image: device:dockerfile imagePullPolicy: Never ports: - - containerPort: 7070 + - containerPort: 2020 env: - name: DB_ENGINE value: "redis" @@ -27,10 +27,10 @@ spec: value: "DEBUG" readinessProbe: exec: - command: ["/bin/grpc_health_probe", "-addr=:7070"] + command: ["/bin/grpc_health_probe", "-addr=:2020"] livenessProbe: exec: - command: ["/bin/grpc_health_probe", "-addr=:7070"] + command: ["/bin/grpc_health_probe", "-addr=:2020"] resources: requests: cpu: 250m @@ -49,5 +49,5 @@ spec: app: deviceservice ports: - name: grpc - port: 7070 - targetPort: 7070 + port: 2020 + targetPort: 2020 diff --git a/src/context/Config.py b/src/context/Config.py index 2f2114d61..4c53fa59b 100644 --- a/src/context/Config.py +++ b/src/context/Config.py @@ -1,10 +1,13 @@ import logging # gRPC settings -SERVICE_PORT = 7070 -MAX_WORKERS = 10 -GRACE_PERIOD = 60 -LOG_LEVEL = logging.WARNING +GRPC_SERVICE_PORT = 1010 +GRPC_MAX_WORKERS = 10 +GRPC_GRACE_PERIOD = 60 +GRPC_LOG_LEVEL = logging.WARNING + +# HTTP settings +HTTP_SERVICE_PORT = 8080 # Prometheus settings -METRICS_PORT = 8080 +METRICS_PORT = 9192 diff --git a/src/device/.gitlab-ci.yml b/src/device/.gitlab-ci.yml index 4a3693932..4311d9a98 100644 --- a/src/device/.gitlab-ci.yml +++ b/src/device/.gitlab-ci.yml @@ -1,10 +1,10 @@ variables: - IMAGE_NAME: 'context' # name of the microservice - IMAGE_NAME_TEST: 'context-test' # name of the microservice + IMAGE_NAME: 'device' # name of the microservice + IMAGE_NAME_TEST: 'device-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) # build the Docker image -build context: +build device: stage: build script: - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ @@ -14,7 +14,7 @@ build context: - .gitlab-ci.yml # tags the Docker image -tag context: +tag device: stage: build script: - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" @@ -24,7 +24,7 @@ tag context: - .gitlab-ci.yml # push the Docker image to the gitlab Docker registry -push context: +push device: stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY @@ -37,10 +37,10 @@ push context: # test if the Docker image can be pulled from the gitlab registry -test context pull: +test device pull: stage: test needs: - - push context + - push device before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: @@ -51,17 +51,17 @@ test context pull: - .gitlab-ci.yml # test if the Docker image can be executed -test context run: +test device run: stage: test needs: - - build context + - build device before_script: - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - - docker run -d -p 1010:1010 --name context --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" + - docker run -d -p 1010:1010 --name device --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" - docker ps > deploy_test_report.txt after_script: - - docker stop context + - docker stop device rules: - changes: - src/$IMAGE_NAME/** @@ -72,11 +72,11 @@ test context run: - deploy_test_report.txt expire_in: 1 day -# apply unit test to the context component -test context pytest: +# apply unit test to the device component +test device pytest: stage: test needs: - - build context + - build device script: - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ > pytest_report.txt rules: @@ -90,11 +90,11 @@ test context pytest: expire_in: 1 day # Deployment of the monitoring service in Kubernetes Cluster -deploy context: +deploy device: stage: deploy needs: - - build context - - test context run + - build device + - test device run script: - - kubectl apply -f "manisfests/contextservice.yaml" + - kubectl apply -f "manisfests/deviceservice.yaml" when: manual diff --git a/src/device/Config.py b/src/device/Config.py index 2f2114d61..438f831a8 100644 --- a/src/device/Config.py +++ b/src/device/Config.py @@ -1,10 +1,10 @@ import logging # gRPC settings -SERVICE_PORT = 7070 -MAX_WORKERS = 10 -GRACE_PERIOD = 60 -LOG_LEVEL = logging.WARNING +GRPC_SERVICE_PORT = 2020 +GRPC_MAX_WORKERS = 10 +GRPC_GRACE_PERIOD = 60 +GRPC_LOG_LEVEL = logging.WARNING # Prometheus settings -METRICS_PORT = 8080 +METRICS_PORT = 9192 -- GitLab