Commit 3a03e5cf authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/320-cttc-ietf-simap-basic-support-with-kafka-yang-push' into 'develop'

Resolve "(CTTC) IETF SIMAP Basic support with Kafka YANG-push"

See merge request !382
parents eddce1f8 3f639a67
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ include:
  - local: '/src/e2e_orchestrator/.gitlab-ci.yml'
  - local: '/src/ztp_server/.gitlab-ci.yml'
  - local: '/src/osm_client/.gitlab-ci.yml'
  - local: '/src/simap_connector/.gitlab-ci.yml'

  # This should be last one: end-to-end integration tests
  - local: '/src/tests/.gitlab-ci.yml'

deploy/build-only.sh

0 → 100755
+143 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


########################################################################################################################
# Read deployment settings
########################################################################################################################


# ----- TeraFlowSDN ------------------------------------------------------------

# If not already set, set the URL of the Docker registry where the images will be uploaded to.
# By default, assume internal MicroK8s registry is used.
export TFS_REGISTRY_IMAGES=${TFS_REGISTRY_IMAGES:-"http://localhost:32000/tfs/"}

# If not already set, set the list of components, separated by spaces, you want to build images for, and deploy.
# By default, only basic components are deployed
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device pathcomp service slice nbi webui load_generator"}

# If not already set, set the tag you want to use for your images.
export TFS_IMAGE_TAG=${TFS_IMAGE_TAG:-"dev"}


########################################################################################################################
# Automated steps start here
########################################################################################################################

# Create a tmp folder for files modified during the deployment
TMP_LOGS_FOLDER="./tmp/build"
mkdir -p $TMP_LOGS_FOLDER

DOCKER_BUILD="docker build"
DOCKER_MAJOR_VERSION=$(docker --version | grep -o -E "Docker version [0-9]+\." | grep -o -E "[0-9]+" | cut -c 1-3)
if [[ $DOCKER_MAJOR_VERSION -ge 23 ]]; then
    # If Docker version >= 23, build command was migrated to docker-buildx
    # In Ubuntu, in practice, means to install package docker-buildx together with docker.io
    # Check if docker-buildx plugin is installed
    docker buildx version 1>/dev/null 2>/dev/null
    if [[ $? -ne 0 ]]; then
        echo "Docker buildx command is not installed. Check: https://docs.docker.com/build/architecture/#install-buildx"
        echo "If you installed docker through APT package docker.io, consider installing also package docker-buildx"
        exit 1;
    fi
    DOCKER_BUILD="docker buildx build"
fi

for COMPONENT in $TFS_COMPONENTS; do
    echo "Processing '$COMPONENT' component..."

    echo "  Building Docker image..."
    BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"

    if [ "$COMPONENT" == "ztp" ] || [ "$COMPONENT" == "policy" ]; then
        $DOCKER_BUILD -t "$COMPONENT:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG"
    elif [ "$COMPONENT" == "pathcomp" ] || [ "$COMPONENT" == "telemetry" ] || [ "$COMPONENT" == "analytics" ]; 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"
        if [ "$COMPONENT" == "pathcomp" ]; then
            # next command is redundant, but helpful to keep cache updated between rebuilds
            IMAGE_NAME="$COMPONENT-backend:$TFS_IMAGE_TAG-builder"
            $DOCKER_BUILD -t "$IMAGE_NAME" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
        fi
    elif [ "$COMPONENT" == "dlt" ]; then
        BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-connector.log"
        $DOCKER_BUILD -t "$COMPONENT-connector:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/connector/Dockerfile . > "$BUILD_LOG"

        BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-gateway.log"
        $DOCKER_BUILD -t "$COMPONENT-gateway:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/gateway/Dockerfile . > "$BUILD_LOG"
    else
        $DOCKER_BUILD -t "$COMPONENT:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG"
    fi

    echo "  Pushing Docker image to '$TFS_REGISTRY_IMAGES'..."

    if [ "$COMPONENT" == "pathcomp" ] || [ "$COMPONENT" == "telemetry" ] || [ "$COMPONENT" == "analytics" ] ; then
        IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT-frontend:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')

        TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-frontend.log"
        docker tag "$COMPONENT-frontend:$TFS_IMAGE_TAG" "$IMAGE_URL" > "$TAG_LOG"

        PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-frontend.log"
        docker push "$IMAGE_URL" > "$PUSH_LOG"

        IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT-backend:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')

        TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-backend.log"
        docker tag "$COMPONENT-backend:$TFS_IMAGE_TAG" "$IMAGE_URL" > "$TAG_LOG"

        PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-backend.log"
        docker push "$IMAGE_URL" > "$PUSH_LOG"
    elif [ "$COMPONENT" == "dlt" ]; then
        IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT-connector:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')

        TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-connector.log"
        docker tag "$COMPONENT-connector:$TFS_IMAGE_TAG" "$IMAGE_URL" > "$TAG_LOG"

        PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-connector.log"
        docker push "$IMAGE_URL" > "$PUSH_LOG"

        IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT-gateway:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')

        TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}-gateway.log"
        docker tag "$COMPONENT-gateway:$TFS_IMAGE_TAG" "$IMAGE_URL" > "$TAG_LOG"

        PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}-gateway.log"
        docker push "$IMAGE_URL" > "$PUSH_LOG"
    else
        IMAGE_URL=$(echo "$TFS_REGISTRY_IMAGES/$COMPONENT:$TFS_IMAGE_TAG" | sed 's,//,/,g' | sed 's,http:/,,g')

        TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}.log"
        docker tag "$COMPONENT:$TFS_IMAGE_TAG" "$IMAGE_URL" > "$TAG_LOG"

        PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log"
        docker push "$IMAGE_URL" > "$PUSH_LOG"
    fi

    printf "\n"
done

echo "Pruning Docker Images..."
docker image prune --force
printf "\n\n"

if [ "$DOCKER_BUILD" == "docker buildx build" ]; then
    echo "Pruning Docker Buildx Cache..."
    docker buildx prune --force
    printf "\n\n"
fi
+7 −0
Original line number Diff line number Diff line
@@ -57,6 +57,13 @@ spec:
                name: webuiservice
                port:
                  number: 3000
          - path: /()(.well-known/.*)
            pathType: Prefix
            backend:
              service:
                name: nbiservice
                port:
                  number: 8080
          - path: /()(restconf/.*)
            pathType: Prefix
            backend:
+100 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: simap-connectorservice
spec:
  selector:
    matchLabels:
      app: simap-connectorservice
  replicas: 1
  template:
    metadata:
      labels:
        app: simap-connectorservice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
        - name: server
          image: labs.etsi.org:5050/tfs/controller/simap_connector:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 9090
            - containerPort: 9192
          env:
            - name: LOG_LEVEL
              value: "INFO"
            - name: SIMAP_SERVER_SCHEME
              value: "http"
            - name: SIMAP_SERVER_ADDRESS
              # Assuming SIMAP Server is deployed in a local Docker container, as per:
              # - ./src/tests/tools/simap_server/build.sh
              # - ./src/tests/tools/simap_server/deploy.sh
              value: "172.17.0.1"
            - name: SIMAP_SERVER_PORT
              # Assuming SIMAP Server is deployed in a local Docker container, as per:
              # - ./src/tests/tools/simap_server/build.sh
              # - ./src/tests/tools/simap_server/deploy.sh
              value: "8080"
            - name: SIMAP_SERVER_USERNAME
              value: "admin"
            - name: SIMAP_SERVER_PASSWORD
              value: "admin"
            - name: CRDB_DATABASE
              value: "tfs_simap_connector"
          envFrom:
            - secretRef:
                name: crdb-data
            - secretRef:
                name: kfk-kpi-data
          startupProbe:
            grpc:
              port: 9090
            failureThreshold: 30
            periodSeconds: 1
          readinessProbe:
            grpc:
              port: 9090
          livenessProbe:
            grpc:
              port: 9090
          resources:
            requests:
              cpu: 250m
              memory: 128Mi
            limits:
              cpu: 1000m
              memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
  name: simap-connectorservice
  labels:
    app: simap-connectorservice
spec:
  type: ClusterIP
  selector:
    app: simap-connectorservice
  ports:
    - name: grpc
      protocol: TCP
      port: 9090
      targetPort: 9090
    - name: metrics
      protocol: TCP
      port: 9192
      targetPort: 9192
+3 −0
Original line number Diff line number Diff line
@@ -86,6 +86,9 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui"
#    export TFS_COMPONENTS="${BEFORE} qkd_app service ${AFTER}"
#fi

# Uncomment to activate SIMAP Connector
#export TFS_COMPONENTS="${TFS_COMPONENTS} simap_connector"

# Uncomment to activate Load Generator
#export TFS_COMPONENTS="${TFS_COMPONENTS} load_generator"

Loading