Loading .gitlab-ci.yml +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ stages: include: - local: '/manifests/.gitlab-ci.yml' #- local: '/src/monitoring/.gitlab-ci.yml' - local: '/src/centralizedcybersecurity/.gitlab-ci.yml' - local: '/src/context/.gitlab-ci.yml' - local: '/src/device/.gitlab-ci.yml' - local: '/src/service/.gitlab-ci.yml' Loading manifests/centralizedcybersecurityservice.yaml 0 → 100644 +70 −0 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Deployment metadata: name: centralizedcybersecurityservice spec: selector: matchLabels: app: centralizedcybersecurityservice template: metadata: labels: app: centralizedcybersecurityservice spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/centralizedcybersecurity:latest imagePullPolicy: Always ports: - containerPort: 10010 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=:10010"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10010"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: centralizedcybersecurityservice spec: type: ClusterIP selector: app: centralizedcybersecurityservice ports: - name: grpc port: 10010 targetPort: 10010 --- apiVersion: v1 kind: Service metadata: name: centralizedcybersecurityservice-public labels: app: centralizedcybersecurityservice spec: type: NodePort selector: app: centralizedcybersecurityservice ports: - name: grpc protocol: TCP port: 10010 targetPort: 10010 --- report_coverage_centralized_cybersecurity.sh 0 → 100755 +3 −0 Original line number Diff line number Diff line #!/bin/bash ./report_coverage_all.sh | grep --color -E -i "^centralizedcybersecurity/.*$|$" run_local_tests.sh +5 −2 Original line number Diff line number Diff line #!/bin/bash cd $(dirname $0)/src RCFILE=~/teraflow/controller/coverage/.coveragerc COVERAGEFILE=~/teraflow/controller/coverage/.coverage RCFILE=~/projects/teraflow/controller/coverage/.coveragerc COVERAGEFILE=~/projects/teraflow/controller/coverage/.coverage # Run unitary tests and analyze coverage of code at same time Loading @@ -13,6 +13,9 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ common/database/tests/test_unitary.py \ common/database/tests/test_engine_inmemory.py coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ centralizedcybersecurity/tests/test_unitary.py coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ context/tests/test_unitary.py Loading src/centralizedcybersecurity/.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 centralizedcybersecurity: variables: IMAGE_NAME: 'centralizedcybersecurity' # name of the microservice IMAGE_NAME_TEST: 'centralizedcybersecurity-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 centralizedcybersecurity: variables: IMAGE_NAME: 'centralizedcybersecurity' # name of the microservice IMAGE_NAME_TEST: 'centralizedcybersecurity-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: - build centralizedcybersecurity 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 3030:3030 --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 centralizedcybersecurity: stage: deploy needs: - build centralizedcybersecurity - unit_test centralizedcybersecurity - dependencies all - integ_test execute script: - kubectl version - kubectl get all - kubectl apply -f "manifests/centralizedcybersecurityservice.yaml" - kubectl delete pods --selector app=centralizedcybersecurityservice - kubectl get all Loading
.gitlab-ci.yml +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ stages: include: - local: '/manifests/.gitlab-ci.yml' #- local: '/src/monitoring/.gitlab-ci.yml' - local: '/src/centralizedcybersecurity/.gitlab-ci.yml' - local: '/src/context/.gitlab-ci.yml' - local: '/src/device/.gitlab-ci.yml' - local: '/src/service/.gitlab-ci.yml' Loading
manifests/centralizedcybersecurityservice.yaml 0 → 100644 +70 −0 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Deployment metadata: name: centralizedcybersecurityservice spec: selector: matchLabels: app: centralizedcybersecurityservice template: metadata: labels: app: centralizedcybersecurityservice spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/centralizedcybersecurity:latest imagePullPolicy: Always ports: - containerPort: 10010 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=:10010"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10010"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: centralizedcybersecurityservice spec: type: ClusterIP selector: app: centralizedcybersecurityservice ports: - name: grpc port: 10010 targetPort: 10010 --- apiVersion: v1 kind: Service metadata: name: centralizedcybersecurityservice-public labels: app: centralizedcybersecurityservice spec: type: NodePort selector: app: centralizedcybersecurityservice ports: - name: grpc protocol: TCP port: 10010 targetPort: 10010 ---
report_coverage_centralized_cybersecurity.sh 0 → 100755 +3 −0 Original line number Diff line number Diff line #!/bin/bash ./report_coverage_all.sh | grep --color -E -i "^centralizedcybersecurity/.*$|$"
run_local_tests.sh +5 −2 Original line number Diff line number Diff line #!/bin/bash cd $(dirname $0)/src RCFILE=~/teraflow/controller/coverage/.coveragerc COVERAGEFILE=~/teraflow/controller/coverage/.coverage RCFILE=~/projects/teraflow/controller/coverage/.coveragerc COVERAGEFILE=~/projects/teraflow/controller/coverage/.coverage # Run unitary tests and analyze coverage of code at same time Loading @@ -13,6 +13,9 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ common/database/tests/test_unitary.py \ common/database/tests/test_engine_inmemory.py coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ centralizedcybersecurity/tests/test_unitary.py coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ context/tests/test_unitary.py Loading
src/centralizedcybersecurity/.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 centralizedcybersecurity: variables: IMAGE_NAME: 'centralizedcybersecurity' # name of the microservice IMAGE_NAME_TEST: 'centralizedcybersecurity-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 centralizedcybersecurity: variables: IMAGE_NAME: 'centralizedcybersecurity' # name of the microservice IMAGE_NAME_TEST: 'centralizedcybersecurity-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: - build centralizedcybersecurity 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 3030:3030 --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 centralizedcybersecurity: stage: deploy needs: - build centralizedcybersecurity - unit_test centralizedcybersecurity - dependencies all - integ_test execute script: - kubectl version - kubectl get all - kubectl apply -f "manifests/centralizedcybersecurityservice.yaml" - kubectl delete pods --selector app=centralizedcybersecurityservice - kubectl get all