Commit 343560cf authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Several changes:

Context service:
- corrected port numbers

Device service:
- corrected port numbers
- upgraded gitlab-ci configuration
parent 6c04b49b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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
+5 −5
Original line number Diff line number Diff line
@@ -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
+8 −5
Original line number Diff line number Diff line
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
+18 −18
Original line number Diff line number Diff line
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
+5 −5
Original line number Diff line number Diff line
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