Loading install_development_dependencies.sh +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ pip install --upgrade pip setuptools wheel pip-tools pylint pytest pytest-benchm echo "" > requirements.in #TODO: include here your component COMPONENTS="compute context device monitoring centralizedattackdetector" COMPONENTS="compute context device monitoring centralizedattackdetector webui" # compiling dependencies from all components for component in $COMPONENTS Loading manifests/webuiservice.yaml 0 → 100644 +70 −0 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Deployment metadata: name: webuiservice spec: selector: matchLabels: app: webuiservice template: metadata: labels: app: webuiservice spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/webui:latest imagePullPolicy: Always ports: - containerPort: 8001 # 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"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10000"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: webuiservice spec: type: ClusterIP selector: app: webuiservice ports: - name: grpc port: 10000 targetPort: 10000 --- 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 --- run_local_tests.sh +12 −8 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ PROJECTDIR=`pwd` cd $(dirname $0)/src cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc COVERAGEFILE=$PROJECTDIR/coverage/.coverage Loading Loading @@ -34,11 +34,15 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ compute/tests/test_unitary.py # Run integration tests and analyze coverage of code at same time export DB_ENGINE='redis' export REDIS_SERVICE_HOST='10.1.7.194' export REDIS_SERVICE_PORT='31789' export REDIS_DATABASE_ID='0' coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ common/database/tests/test_engine_redis.py \ tester_integration/test_context_device_service.py webui/tests/test_unitary.py # Run integration tests and analyze coverage of code at same time #TODO: umcomment the following lines # export DB_ENGINE='redis' # export REDIS_SERVICE_HOST='10.1.7.194' # export REDIS_SERVICE_PORT='31789' # export REDIS_DATABASE_ID='0' # coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ # common/database/tests/test_engine_redis.py \ # tester_integration/test_context_device_service.py src/webui/.gitlab-ci.yml 0 → 100644 +60 −0 Original line number Diff line number Diff line # Build, tag, and push the Docker images to the GitLab Docker registry build webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME_TEST: 'webui-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # Pull, execute, and run unitary tests for the Docker image from the GitLab registry unit_test webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME_TEST: 'webui-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: - build webui before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker run -d -p 10000:10000 --name $IMAGE_NAME --network=teraflowbridge "$IMAGE_NAME:$IMAGE_TAG" - docker ps -a - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py" after_script: - docker stop $IMAGE_NAME - docker rm $IMAGE_NAME rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # Deployment of the service in Kubernetes Cluster deploy webui: stage: deploy needs: - build webui - unit_test webui - dependencies all - integ_test execute script: - kubectl version - kubectl get all - kubectl apply -f "manifests/webuiservice.yaml" - kubectl delete pods --selector app=webuiservice - kubectl get all src/webui/Config.py 0 → 100644 +16 −0 Original line number Diff line number Diff line import logging # General settings LOG_LEVEL = logging.WARNING # gRPC settings WEBUI_SERVICE_PORT = 8004 # Prometheus settings METRICS_PORT = 9192 SECRET_KEY = '>s&}24@{]]#k3&^5$f3#?6?h3{W@[}/7z}2pa]>{3&5%RP<)[(' HOST = '0.0.0.0' # accepts connections coming from any IP DEBUG=False Loading
install_development_dependencies.sh +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ pip install --upgrade pip setuptools wheel pip-tools pylint pytest pytest-benchm echo "" > requirements.in #TODO: include here your component COMPONENTS="compute context device monitoring centralizedattackdetector" COMPONENTS="compute context device monitoring centralizedattackdetector webui" # compiling dependencies from all components for component in $COMPONENTS Loading
manifests/webuiservice.yaml 0 → 100644 +70 −0 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Deployment metadata: name: webuiservice spec: selector: matchLabels: app: webuiservice template: metadata: labels: app: webuiservice spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/webui:latest imagePullPolicy: Always ports: - containerPort: 8001 # 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"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10000"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: webuiservice spec: type: ClusterIP selector: app: webuiservice ports: - name: grpc port: 10000 targetPort: 10000 --- 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 ---
run_local_tests.sh +12 −8 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ PROJECTDIR=`pwd` cd $(dirname $0)/src cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc COVERAGEFILE=$PROJECTDIR/coverage/.coverage Loading Loading @@ -34,11 +34,15 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ compute/tests/test_unitary.py # Run integration tests and analyze coverage of code at same time export DB_ENGINE='redis' export REDIS_SERVICE_HOST='10.1.7.194' export REDIS_SERVICE_PORT='31789' export REDIS_DATABASE_ID='0' coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ common/database/tests/test_engine_redis.py \ tester_integration/test_context_device_service.py webui/tests/test_unitary.py # Run integration tests and analyze coverage of code at same time #TODO: umcomment the following lines # export DB_ENGINE='redis' # export REDIS_SERVICE_HOST='10.1.7.194' # export REDIS_SERVICE_PORT='31789' # export REDIS_DATABASE_ID='0' # coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ # common/database/tests/test_engine_redis.py \ # tester_integration/test_context_device_service.py
src/webui/.gitlab-ci.yml 0 → 100644 +60 −0 Original line number Diff line number Diff line # Build, tag, and push the Docker images to the GitLab Docker registry build webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME_TEST: 'webui-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # Pull, execute, and run unitary tests for the Docker image from the GitLab registry unit_test webui: variables: IMAGE_NAME: 'webui' # name of the microservice IMAGE_NAME_TEST: 'webui-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: - build webui before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker run -d -p 10000:10000 --name $IMAGE_NAME --network=teraflowbridge "$IMAGE_NAME:$IMAGE_TAG" - docker ps -a - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py" after_script: - docker stop $IMAGE_NAME - docker rm $IMAGE_NAME rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # Deployment of the service in Kubernetes Cluster deploy webui: stage: deploy needs: - build webui - unit_test webui - dependencies all - integ_test execute script: - kubectl version - kubectl get all - kubectl apply -f "manifests/webuiservice.yaml" - kubectl delete pods --selector app=webuiservice - kubectl get all
src/webui/Config.py 0 → 100644 +16 −0 Original line number Diff line number Diff line import logging # General settings LOG_LEVEL = logging.WARNING # gRPC settings WEBUI_SERVICE_PORT = 8004 # Prometheus settings METRICS_PORT = 9192 SECRET_KEY = '>s&}24@{]]#k3&^5$f3#?6?h3{W@[}/7z}2pa]>{3&5%RP<)[(' HOST = '0.0.0.0' # accepts connections coming from any IP DEBUG=False