Loading common_requirements.in +1 −0 Original line number Diff line number Diff line Loading @@ -6,3 +6,4 @@ prometheus-client==0.13.0 protobuf==3.20.* pytest==6.2.5 pytest-benchmark==3.4.1 python-dateutil==2.8.2 deploy.sh +53 −10 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ for COMPONENT in $TFS_COMPONENTS; do if [ "$COMPONENT" == "automation" ] || [ "$COMPONENT" == "policy" ]; then docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG" elif [ "$COMPONENT" == "pathcomp" ]; then BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-frontend.log" docker build -t "$COMPONENT-frontend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/frontend/Dockerfile . >> "$BUILD_LOG" BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-backend.log" docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG" # next command is redundant, but helpful to keep cache updated between rebuilds docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG-builder" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG" else docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG" fi Loading @@ -93,27 +101,62 @@ for COMPONENT in $TFS_COMPONENTS; do if [ -n "$TFS_REGISTRY_IMAGE" ]; then echo " Pushing Docker image to '$TFS_REGISTRY_IMAGE'..." if [ "$COMPONENT" == "pathcomp" ]; then TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-frontend.log" docker tag "$COMPONENT-frontend:$TFS_IMAGE_TAG" "$IMAGE_URL-frontend" > "$TAG_LOG" TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-backend.log" docker tag "$COMPONENT-backend:$TFS_IMAGE_TAG" "$IMAGE_URL-backend" > "$TAG_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-frontend.log" docker push "$IMAGE_URL-frontend" > "$PUSH_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-backend.log" docker push "$IMAGE_URL-backend" > "$PUSH_LOG" else TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}.log" docker tag "$IMAGE_NAME" "$IMAGE_URL" > "$TAG_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log" docker push "$IMAGE_URL" > "$PUSH_LOG" fi fi echo " Adapting '$COMPONENT' manifest file..." MANIFEST="$TMP_MANIFESTS_FOLDER/${COMPONENT}service.yaml" cp ./manifests/"${COMPONENT}"service.yaml "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) if [ -n "$TFS_REGISTRY_IMAGE" ]; then # Registry is set if [ "$COMPONENT" == "pathcomp" ]; then VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-frontend:${VERSION}#image: $IMAGE_URL-frontend#g" "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-backend:${VERSION}#image: $IMAGE_URL-backend#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" else VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" fi else # Registry is not set if [ "$COMPONENT" == "pathcomp" ]; then VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-frontend:${VERSION}#image: $IMAGE_NAME-frontend#g" "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-backend:${VERSION}#image: $IMAGE_NAME-backend#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST" else VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_NAME#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST" fi fi echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/deploy_${COMPONENT}.log" Loading expose_ingress_grpc.sh +2 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} # If not already set, set the list of components you want to build images for, and deploy. export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation policy service compute monitoring dbscanserving opticalattackmitigator opticalcentralizedattackdetector webui"} Loading @@ -32,6 +32,7 @@ for COMPONENT in $TFS_COMPONENTS; do echo "Processing '$COMPONENT' component..." SERVICE_GRPC_PORT=$(kubectl get service ${COMPONENT}service --namespace $TFS_K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.name=="grpc")].port}') echo " '$COMPONENT' service port: $SERVICE_GRPC_PORT" if [ -z "${SERVICE_GRPC_PORT}" ]; then printf "\n" continue; Loading manifests/monitoringservice.yaml +25 −14 Original line number Diff line number Diff line Loading @@ -29,19 +29,23 @@ spec: terminationGracePeriodSeconds: 5 restartPolicy: Always containers: - name: influxdb image: influxdb:1.8 - name: metricsdb image: questdb/questdb ports: - containerPort: 8086 envFrom: - secretRef: name: influxdb-secrets - containerPort: 9000 - containerPort: 9009 - containerPort: 9003 env: - name: QDB_CAIRO_COMMIT_LAG value: "1000" - name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS value: "100000" readinessProbe: exec: command: ["curl", "-XGET", "localhost:8086/health"] command: ["curl", "-XGET", "localhost:9000"] livenessProbe: exec: command: ["curl", "-XGET", "localhost:8086/health"] command: ["curl", "-XGET", "localhost:9003/metrics"] resources: requests: cpu: 250m Loading @@ -54,9 +58,15 @@ spec: imagePullPolicy: Always ports: - containerPort: 7070 envFrom: - secretRef: name: monitoring-secrets env: - name: METRICSDB_HOSTNAME value: "localhost" - name: METRICSDB_ILP_PORT value: "9009" - name: METRICSDB_REST_PORT value: "9000" - name: METRICSDB_TABLE value: "monitoring" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:7070"] Loading @@ -70,6 +80,7 @@ spec: limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service Loading @@ -84,7 +95,7 @@ spec: protocol: TCP port: 7070 targetPort: 7070 - name: influxdb - name: questdb protocol: TCP port: 8086 targetPort: 8086 port: 9000 targetPort: 9000 No newline at end of file manifests/pathcompservice.yaml +37 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ spec: spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/pathcomp:latest - name: frontend image: registry.gitlab.com/teraflow-h2020/controller/pathcomp-frontend:latest imagePullPolicy: Always ports: - containerPort: 10020 Loading @@ -48,6 +48,37 @@ spec: limits: cpu: 700m memory: 1024Mi - name: backend image: registry.gitlab.com/teraflow-h2020/controller/pathcomp-backend:latest imagePullPolicy: Always # not working; to be investigated #readinessProbe: # exec: # command: # - curl -X POST -0 # - -H 'Expect:' # - -H 'Content-Type:\ application/json' # - -d '{}' # - http://127.0.0.1:8081/pathComp/api/v1/compRoute # initialDelaySeconds: 5 # timeoutSeconds: 5 #livenessProbe: # exec: # command: # - curl -X POST -0 # - -H 'Expect:' # - -H 'Content-Type:\ application/json' # - -d '{}' # - http://127.0.0.1:8081/pathComp/api/v1/compRoute # initialDelaySeconds: 5 # timeoutSeconds: 5 resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service Loading @@ -62,3 +93,7 @@ spec: protocol: TCP port: 10020 targetPort: 10020 - name: http protocol: TCP port: 8081 targetPort: 8081 Loading
common_requirements.in +1 −0 Original line number Diff line number Diff line Loading @@ -6,3 +6,4 @@ prometheus-client==0.13.0 protobuf==3.20.* pytest==6.2.5 pytest-benchmark==3.4.1 python-dateutil==2.8.2
deploy.sh +53 −10 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ for COMPONENT in $TFS_COMPONENTS; do if [ "$COMPONENT" == "automation" ] || [ "$COMPONENT" == "policy" ]; then docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG" elif [ "$COMPONENT" == "pathcomp" ]; then BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-frontend.log" docker build -t "$COMPONENT-frontend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/frontend/Dockerfile . >> "$BUILD_LOG" BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-backend.log" docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG" # next command is redundant, but helpful to keep cache updated between rebuilds docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG-builder" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG" else docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG" fi Loading @@ -93,27 +101,62 @@ for COMPONENT in $TFS_COMPONENTS; do if [ -n "$TFS_REGISTRY_IMAGE" ]; then echo " Pushing Docker image to '$TFS_REGISTRY_IMAGE'..." if [ "$COMPONENT" == "pathcomp" ]; then TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-frontend.log" docker tag "$COMPONENT-frontend:$TFS_IMAGE_TAG" "$IMAGE_URL-frontend" > "$TAG_LOG" TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-backend.log" docker tag "$COMPONENT-backend:$TFS_IMAGE_TAG" "$IMAGE_URL-backend" > "$TAG_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-frontend.log" docker push "$IMAGE_URL-frontend" > "$PUSH_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-backend.log" docker push "$IMAGE_URL-backend" > "$PUSH_LOG" else TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}.log" docker tag "$IMAGE_NAME" "$IMAGE_URL" > "$TAG_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log" docker push "$IMAGE_URL" > "$PUSH_LOG" fi fi echo " Adapting '$COMPONENT' manifest file..." MANIFEST="$TMP_MANIFESTS_FOLDER/${COMPONENT}service.yaml" cp ./manifests/"${COMPONENT}"service.yaml "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) if [ -n "$TFS_REGISTRY_IMAGE" ]; then # Registry is set if [ "$COMPONENT" == "pathcomp" ]; then VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-frontend:${VERSION}#image: $IMAGE_URL-frontend#g" "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-backend:${VERSION}#image: $IMAGE_URL-backend#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" else VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" fi else # Registry is not set if [ "$COMPONENT" == "pathcomp" ]; then VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-frontend:${VERSION}#image: $IMAGE_NAME-frontend#g" "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-backend:${VERSION}#image: $IMAGE_NAME-backend#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST" else VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_NAME#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST" fi fi echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/deploy_${COMPONENT}.log" Loading
expose_ingress_grpc.sh +2 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} # If not already set, set the list of components you want to build images for, and deploy. export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation policy service compute monitoring dbscanserving opticalattackmitigator opticalcentralizedattackdetector webui"} Loading @@ -32,6 +32,7 @@ for COMPONENT in $TFS_COMPONENTS; do echo "Processing '$COMPONENT' component..." SERVICE_GRPC_PORT=$(kubectl get service ${COMPONENT}service --namespace $TFS_K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.name=="grpc")].port}') echo " '$COMPONENT' service port: $SERVICE_GRPC_PORT" if [ -z "${SERVICE_GRPC_PORT}" ]; then printf "\n" continue; Loading
manifests/monitoringservice.yaml +25 −14 Original line number Diff line number Diff line Loading @@ -29,19 +29,23 @@ spec: terminationGracePeriodSeconds: 5 restartPolicy: Always containers: - name: influxdb image: influxdb:1.8 - name: metricsdb image: questdb/questdb ports: - containerPort: 8086 envFrom: - secretRef: name: influxdb-secrets - containerPort: 9000 - containerPort: 9009 - containerPort: 9003 env: - name: QDB_CAIRO_COMMIT_LAG value: "1000" - name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS value: "100000" readinessProbe: exec: command: ["curl", "-XGET", "localhost:8086/health"] command: ["curl", "-XGET", "localhost:9000"] livenessProbe: exec: command: ["curl", "-XGET", "localhost:8086/health"] command: ["curl", "-XGET", "localhost:9003/metrics"] resources: requests: cpu: 250m Loading @@ -54,9 +58,15 @@ spec: imagePullPolicy: Always ports: - containerPort: 7070 envFrom: - secretRef: name: monitoring-secrets env: - name: METRICSDB_HOSTNAME value: "localhost" - name: METRICSDB_ILP_PORT value: "9009" - name: METRICSDB_REST_PORT value: "9000" - name: METRICSDB_TABLE value: "monitoring" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:7070"] Loading @@ -70,6 +80,7 @@ spec: limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service Loading @@ -84,7 +95,7 @@ spec: protocol: TCP port: 7070 targetPort: 7070 - name: influxdb - name: questdb protocol: TCP port: 8086 targetPort: 8086 port: 9000 targetPort: 9000 No newline at end of file
manifests/pathcompservice.yaml +37 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ spec: spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/pathcomp:latest - name: frontend image: registry.gitlab.com/teraflow-h2020/controller/pathcomp-frontend:latest imagePullPolicy: Always ports: - containerPort: 10020 Loading @@ -48,6 +48,37 @@ spec: limits: cpu: 700m memory: 1024Mi - name: backend image: registry.gitlab.com/teraflow-h2020/controller/pathcomp-backend:latest imagePullPolicy: Always # not working; to be investigated #readinessProbe: # exec: # command: # - curl -X POST -0 # - -H 'Expect:' # - -H 'Content-Type:\ application/json' # - -d '{}' # - http://127.0.0.1:8081/pathComp/api/v1/compRoute # initialDelaySeconds: 5 # timeoutSeconds: 5 #livenessProbe: # exec: # command: # - curl -X POST -0 # - -H 'Expect:' # - -H 'Content-Type:\ application/json' # - -d '{}' # - http://127.0.0.1:8081/pathComp/api/v1/compRoute # initialDelaySeconds: 5 # timeoutSeconds: 5 resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service Loading @@ -62,3 +93,7 @@ spec: protocol: TCP port: 10020 targetPort: 10020 - name: http protocol: TCP port: 8081 targetPort: 8081