diff --git a/manifests/monitoringservice.yaml b/manifests/monitoring.yaml similarity index 81% rename from manifests/monitoringservice.yaml rename to manifests/monitoring.yaml index bf886f4f9643676e22173537a1de4523f95386ae..f115e5f163eb5d4e58aa92fe11f7d02a1f55f402 100644 --- a/manifests/monitoringservice.yaml +++ b/manifests/monitoring.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: monitoringservice + name: monitoring spec: selector: matchLabels: - app: monitoringservice + app: monitoring template: metadata: labels: - app: monitoringservice + app: monitoring spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: myregistrydomain.com/monitoringservice + image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest ports: - containerPort: 8080 env: @@ -39,11 +39,11 @@ spec: apiVersion: v1 kind: Service metadata: - name: monitoringservice + name: monitoring spec: type: ClusterIP selector: - app: monitoringservice + app: monitoring ports: - name: grpc port: 8080 diff --git a/src/monitoring/.gitlab-ci.yml b/src/monitoring/.gitlab-ci.yml index 27a0f3b855eb1d1953e289d92906dc84b077b5eb..3a99ce18a2b8fbb4d56d33365218696d2184f2de 100644 --- a/src/monitoring/.gitlab-ci.yml +++ b/src/monitoring/.gitlab-ci.yml @@ -2,7 +2,6 @@ build monitoring: variables: IMAGE_NAME: 'monitoring' # name of the microservice - IMAGE_NAME_TEST: 'monitoring-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: build before_script: @@ -17,13 +16,13 @@ build monitoring: - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile + - manifests/$IMAGE_NAME.yaml - .gitlab-ci.yml # test if the Docker image can be pulled from the gitlab registry test monitoring pull: variables: IMAGE_NAME: 'monitoring' # name of the microservice - IMAGE_NAME_TEST: 'monitoring-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: test needs: @@ -38,13 +37,13 @@ test monitoring pull: - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile + - manifests/$IMAGE_NAME.yaml - .gitlab-ci.yml # test if the Docker image can be executed test monitoring run: variables: IMAGE_NAME: 'monitoring' # name of the microservice - IMAGE_NAME_TEST: 'monitoring-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: test needs: @@ -52,7 +51,7 @@ test monitoring run: 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 7070:7070 --name monitoring --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" + - docker run -d -p 7070:7070 --name $IMAGE_NAME --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" - docker ps after_script: - docker stop monitoring @@ -62,6 +61,7 @@ test monitoring run: - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile + - manifests/$IMAGE_NAME.yaml - .gitlab-ci.yml # apply unit test to the monitoring component @@ -75,33 +75,42 @@ test monitoring pytest: - build monitoring script: - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ - - docker run -v "$PWD/src/monitoring/tests:/opt/results" monitoring-test:latest + - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" $IMAGE_NAME_TEST:$IMAGE_TAG rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile + - manifests/$IMAGE_NAME.yaml - .gitlab-ci.yml artifacts: when: always reports: - junit: src/monitoring/tests/report.xml + junit: src/$IMAGE_NAME/tests/report.xml # Deployment of the monitoring service in Kubernetes Cluster -#deploy monitoring development: -# variables: -# IMAGE_NAME: 'monitoring' # name of the microservice -# IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) -# stage: deploy -# needs: -# - build monitoring -# - test monitoring run -# script: -# - kubectl version -# - kubectl get all -# - kubectl apply -f "manifests/monitoringservice.yaml" -# - kubectl get all -# when: manual +deploy monitoring development: + variables: + IMAGE_NAME: 'monitoring' # name of the microservice + IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) + stage: deploy + needs: + - build monitoring + - test monitoring run + script: + - kubectl version + - kubectl get all + - kubectl apply -f "manifests/$IMAGE_NAME.yaml" + - kubectl get all + when: manual + rules: + - changes: + - src/$IMAGE_NAME/*.{py,in,yml} + - src/$IMAGE_NAME/Dockerfile + - src/$IMAGE_NAME/tests/*.py + - src/$IMAGE_NAME/tests/Dockerfile + - manifests/$IMAGE_NAME.yaml + - .gitlab-ci.yml