Commit bc04fd37 authored by Sergio Gonzalez Diaz's avatar Sergio Gonzalez Diaz
Browse files

delete monitoring service

parent eb3cc115
Loading
Loading
Loading
Loading
+93 −51
Original line number Diff line number Diff line
# apiVersion: apps/v1
# kind: Deployment
# metadata:
#   name: monitoring
# spec:
#   selector:
#     matchLabels:
#       app: monitoring
#   template:
#     metadata:
#       labels:
#         app: monitoring
#     spec:
#       terminationGracePeriodSeconds: 5
#       containers:
#       - name: server
#         image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest
#         imagePullPolicy: Always
#         ports:
#         - containerPort: 8080
# ---
# apiVersion: v1
# kind: Service
# metadata:
#   name: monitoring
# spec:
#   type: ClusterIP
#   selector:
#     app: monitoring
#   ports:
#   - name: grpc
#     protocol: TCP
#     port: 8080
#     targetPort: 8080
# ---







apiVersion: apps/v1
kind: Deployment
metadata:
@@ -14,40 +56,40 @@ spec:
    spec:
      terminationGracePeriodSeconds: 5
      containers:
      # - name: influxdb
      #   image: influxdb:1.8
      #   ports:
      #   - containerPort: 8086
      #   resources:
      #     requests:
      #       cpu: 250m
      #       memory: 512Mi
      #     limits:
      #       cpu: 700m
      #       memory: 1024Mi
      - name: influxdb
        image: influxdb:1.8
        ports:
        - containerPort: 8086
        resources:
          requests:
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 700m
            memory: 1024Mi
      - name: server
        image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        # env:
        # - name: PORT
        #   value: "8080"
        # readinessProbe:
        #   exec:
        #     command: ["/bin/grpc_health_probe", "-addr=:8080"]
        # livenessProbe:
        #   exec:
        #     command: ["/bin/grpc_health_probe", "-addr=:8080"]
      #   resources:
      #     requests:
      #       cpu: 250m
      #       memory: 512Mi
      #     limits:
      #       cpu: 700m
      #       memory: 1024Mi
      # imagePullSecrets:
      # - name: regcred
        env:
        - name: PORT
          value: "8080"
        readinessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:8080"]
        livenessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:8080"]
        resources:
          requests:
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 700m
            memory: 1024Mi
      imagePullSecrets:
      - name: regcred
---
apiVersion: v1
kind: Service
@@ -62,25 +104,25 @@ spec:
    protocol: TCP
    port: 8080
    targetPort: 8080
  # - name: influxdb
  #   protocol: TCP
  #   port: 8086
  #   targetPort: 8086
# ---
# apiVersion: v1
# kind: Service
# metadata:
#   name: monitoring-public
# spec:
#   type: NodePort
#   selector:
#     app: monitoring
#   ports:
#   - name: grpc
#     protocol: TCP
#     port: 8080
#     targetPort: 8080
#   - name: influxdb
#     protocol: TCP
#     port: 8086
#     targetPort: 8086
 No newline at end of file
  - name: influxdb
    protocol: TCP
    port: 8086
    targetPort: 8086
---
apiVersion: v1
kind: Service
metadata:
  name: monitoring-public
spec:
  type: NodePort
  selector:
    app: monitoring
  ports:
  - name: grpc
    protocol: TCP
    port: 8080
    targetPort: 8080
  - name: influxdb
    protocol: TCP
    port: 8086
    targetPort: 8086
 No newline at end of file
+167 −167
Original line number Diff line number Diff line
# build, tag and push the Docker image to the gitlab registry
build monitoring:
  variables:
    IMAGE_NAME: 'monitoring' # 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"
  after_script:
    - docker rmi $(docker images --quiet --filter=dangling=true)
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
    - 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
# build monitoring:
#   variables:
#     IMAGE_NAME: 'monitoring' # 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"
#   after_script:
#     - docker rmi $(docker images --quiet --filter=dangling=true)
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#     - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
#     - 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

build influx:
  stage: build
@@ -30,11 +30,11 @@ build influx:
    - kubectl get all
    - kubectl delete -f "manifests/monitoring.yaml"
    # - kubectl delete -f "manifests/influx.yaml"
    - sleep 60
    - kubectl get all
    - kubectl apply -f "manifests/monitoring.yaml"
    - sleep 60
    - kubectl get all
    # - sleep 60
    # - kubectl get all
    # - kubectl apply -f "manifests/monitoring.yaml"
    # - sleep 60
    # - kubectl get all
    # - kubectl apply -f "manifests/influx.yaml"
    # - sleep 15
    # - kubectl get all
@@ -42,152 +42,152 @@ build influx:
    # - kubectl delete -f "manifests/influx.yaml"

# test if the Docker image can be pulled from the gitlab registry
test monitoring pull:
  variables:
    IMAGE_NAME: 'monitoring' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: unit_test
  needs:
    - build monitoring
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
    - 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
# test monitoring pull:
#   variables:
#     IMAGE_NAME: 'monitoring' # name of the microservice
#     IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#   stage: unit_test
#   needs:
#     - build monitoring
#   before_script:
#     - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
#   script:
#     - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#     - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
#     - 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

# test if the Docker image can be executed
test monitoring run:
  variables:
    IMAGE_NAME: 'monitoring' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: unit_test
  needs:
    - build monitoring
  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 $IMAGE_NAME --network=teraflowbridge --rm "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker ps
  after_script:
    - docker stop "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
    - 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
# test monitoring run:
#   variables:
#     IMAGE_NAME: 'monitoring' # name of the microservice
#     IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#   stage: unit_test
#   needs:
#     - build monitoring
#   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 $IMAGE_NAME --network=teraflowbridge --rm "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
#     - docker ps
#   after_script:
#     - docker stop "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#     - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
#     - 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

# apply unit test to the monitoring component
test monitoring pytest:
  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: unit_test
  needs:
    - build monitoring
  script:
    - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/
    - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" $IMAGE_NAME_TEST:$IMAGE_TAG
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
    - 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/$IMAGE_NAME/tests/report.xml
# test monitoring pytest:
#   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: unit_test
#   needs:
#     - build monitoring
#   script:
#     - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/
#     - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" $IMAGE_NAME_TEST:$IMAGE_TAG
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#     - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' 
#     - 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/$IMAGE_NAME/tests/report.xml

# Deployment of the monitoring service in testing Kubernetes Cluster
deploy monitoring test:
  variables:
    IMAGE_NAME: 'monitoring' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: deploy
  needs:
    - test monitoring pull
    - test monitoring run
    - test monitoring pytest
  script:
    - 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/$IMAGE_NAME.yaml"
    - kubectl get all
  # environment:
  #   name: test
  #   url: https://example.com
  #   kubernetes:
  #     namespace: test
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'
      when: manual
# deploy monitoring test:
#   variables:
#     IMAGE_NAME: 'monitoring' # name of the microservice
#     IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#   stage: deploy
#   needs:
#     - test monitoring pull
#     - test monitoring run
#     - test monitoring pytest
#   script:
#     - 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
#     - kubectl version
#     - kubectl get all
#     - kubectl apply -f "manifests/$IMAGE_NAME.yaml"
#     - kubectl get all
#   # environment:
#   #   name: test
#   #   url: https://example.com
#   #   kubernetes:
#   #     namespace: test
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'
#       when: manual

# Deployment of the monitoring service in development 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:
    - test monitoring pull
    - test monitoring run
    - test monitoring pytest
  script:
    - 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/$IMAGE_NAME.yaml"
    - kubectl get all
  # environment:
  #   name: development
  #   url: https://example.com
  #   kubernetes:
  #     namespace: development
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
      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:
#     - test monitoring pull
#     - test monitoring run
#     - test monitoring pytest
#   script:
#     - 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
#     - kubectl version
#     - kubectl get all
#     - kubectl apply -f "manifests/$IMAGE_NAME.yaml"
#     - kubectl get all
#   # environment:
#   #   name: development
#   #   url: https://example.com
#   #   kubernetes:
#   #     namespace: development
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#       when: manual

# Deployment of the monitoring service in production Kubernetes Cluster
deploy monitoring production:
  variables:
    IMAGE_NAME: 'monitoring' # name of the microservice
    IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
  stage: deploy
  needs:
    - test monitoring pull
    - test monitoring run
    - test monitoring pytest
  script:
    - 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/$IMAGE_NAME.yaml"
    - kubectl get all
  # environment:
  #   name: production
  #   url: https://example.com
  #   kubernetes:
  #     namespace: production
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
      when: manual
# deploy monitoring production:
#   variables:
#     IMAGE_NAME: 'monitoring' # name of the microservice
#     IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#   stage: deploy
#   needs:
#     - test monitoring pull
#     - test monitoring run
#     - test monitoring pytest
#   script:
#     - 'sed -i "s/image: .*/image: $CI_REGISTRY\/$CI_PROJECT_NAMESPACE\/$CI_PROJECT_NAME\/$IMAGE_NAME:$IMAGE_TAG/" manifests/$IMAGE_NAME.yaml'
#     - kubectl version
#     - kubectl get all
#     - kubectl apply -f "manifests/$IMAGE_NAME.yaml"
#     - kubectl get all
#   # environment:
#   #   name: production
#   #   url: https://example.com
#   #   kubernetes:
#   #     namespace: production
#   rules:
#     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
#       when: manual