Loading deploy/mock_blockchain.sh +9 −8 Original line number Diff line number Diff line Loading @@ -38,20 +38,21 @@ GITLAB_REPO_URL="labs.etsi.org:5050/tfs/controller" TMP_FOLDER="./tmp" # Create a tmp folder for files modified during the deployment TMP_MANIFESTS_FOLDER="$TMP_FOLDER/manifests" TMP_MANIFESTS_FOLDER="${TMP_FOLDER}/${K8S_NAMESPACE}/manifests" mkdir -p $TMP_MANIFESTS_FOLDER TMP_LOGS_FOLDER="$TMP_FOLDER/logs" TMP_LOGS_FOLDER="${TMP_FOLDER}/${K8S_NAMESPACE}/logs" mkdir -p $TMP_LOGS_FOLDER echo "Deleting and Creating a new namespace..." kubectl delete namespace $K8S_NAMESPACE kubectl delete namespace $K8S_NAMESPACE --ignore-not-found kubectl create namespace $K8S_NAMESPACE printf "\n" echo "Deploying components and collecting environment variables..." ENV_VARS_SCRIPT=tfs_bchain_runtime_env_vars.sh echo "# Environment variables for TeraFlow Mock-Blockchain deployment" > $ENV_VARS_SCRIPT echo "# Environment variables for TeraFlowSDN Mock-Blockchain deployment" > $ENV_VARS_SCRIPT PYTHONPATH=$(pwd)/src echo "export PYTHONPATH=${PYTHONPATH}" >> $ENV_VARS_SCRIPT echo "Processing '$COMPONENT' component..." IMAGE_NAME="$COMPONENT:$IMAGE_TAG" Loading @@ -77,12 +78,12 @@ cp ./manifests/"${COMPONENT}".yaml "$MANIFEST" if [ -n "$REGISTRY_IMAGE" ]; then # Registry is set VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" else # Registry is not set VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4) 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 Loading @@ -91,8 +92,8 @@ echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/deploy_${COMPONENT}.log" kubectl --namespace $K8S_NAMESPACE apply -f "$MANIFEST" > "$DEPLOY_LOG" COMPONENT_OBJNAME=$(echo "${COMPONENT}" | sed "s/\_/-/") kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=0 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=1 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" #kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=0 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" #kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=1 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" echo " Collecting env-vars for '$COMPONENT' component..." SERVICE_DATA=$(kubectl get service ${COMPONENT_OBJNAME} --namespace $K8S_NAMESPACE -o json) Loading deploy/tfs.sh +1 −1 Original line number Diff line number Diff line Loading @@ -348,7 +348,7 @@ for COMPONENT in $TFS_COMPONENTS; do printf "\n" done if [[ "$TFS_COMPONENTS" == *"webui"* ]]; then if [[ "$TFS_COMPONENTS" == *"monitoring"* ]] && [[ "$TFS_COMPONENTS" == *"webui"* ]]; then echo "Configuring WebUI DataStores and Dashboards..." sleep 5 Loading manifests/deviceservice.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ spec: exec: command: ["/bin/grpc_health_probe", "-addr=:2020"] failureThreshold: 30 periodSeconds: 10 periodSeconds: 1 readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:2020"] Loading manifests/webuiservice.yaml +9 −8 Original line number Diff line number Diff line Loading @@ -74,26 +74,27 @@ spec: - name: GF_SERVER_SERVE_FROM_SUB_PATH value: "true" readinessProbe: failureThreshold: 3 failureThreshold: 60 httpGet: path: /robots.txt #path: /robots.txt path: /login port: 3000 scheme: HTTP initialDelaySeconds: 10 periodSeconds: 30 initialDelaySeconds: 1 periodSeconds: 1 successThreshold: 1 timeoutSeconds: 2 livenessProbe: failureThreshold: 3 initialDelaySeconds: 30 periodSeconds: 10 failureThreshold: 60 initialDelaySeconds: 1 periodSeconds: 1 successThreshold: 1 tcpSocket: port: 3000 timeoutSeconds: 1 resources: requests: cpu: 150m cpu: 250m memory: 512Mi limits: cpu: 500m Loading src/common/message_broker/backend/nats/NatsBackendThread.py +21 −17 Original line number Diff line number Diff line Loading @@ -52,9 +52,11 @@ class NatsBackendThread(threading.Thread): self, topic_name : str, timeout : float, out_queue : queue.Queue[Message], unsubscribe : threading.Event, ready_event : threading.Event ) -> None: try: LOGGER.info('[_run_subscriber] NATS URI: {:s}'.format(str(self._nats_uri))) client = await nats.connect(servers=[self._nats_uri]) LOGGER.info('[_run_subscriber] Connected!') server_version = client.connected_server_version LOGGER.info('[_run_subscriber] Connected! NATS Server version: {:s}'.format(str(repr(server_version)))) subscription = await client.subscribe(topic_name) LOGGER.info('[_run_subscriber] Subscribed!') ready_event.set() Loading @@ -68,6 +70,8 @@ class NatsBackendThread(threading.Thread): out_queue.put(Message(message.subject, message.data.decode('UTF-8'))) await subscription.unsubscribe() await client.drain() except Exception: # pylint: disable=broad-exception-caught LOGGER.exception('[_run_subscriber] Unhandled Exception') def subscribe( self, topic_name : str, timeout : float, out_queue : queue.Queue[Message], unsubscribe : threading.Event Loading @@ -79,7 +83,7 @@ class NatsBackendThread(threading.Thread): self._tasks.append(task) LOGGER.info('[subscribe] Waiting for subscriber to be ready...') is_ready = ready_event.wait(timeout=120) LOGGER.info('[subscribe] Subscriber Ready: {:s}'.format(str(is_ready))) LOGGER.info('[subscribe] Subscriber is Ready? {:s}'.format(str(is_ready))) def run(self) -> None: asyncio.set_event_loop(self._event_loop) Loading Loading
deploy/mock_blockchain.sh +9 −8 Original line number Diff line number Diff line Loading @@ -38,20 +38,21 @@ GITLAB_REPO_URL="labs.etsi.org:5050/tfs/controller" TMP_FOLDER="./tmp" # Create a tmp folder for files modified during the deployment TMP_MANIFESTS_FOLDER="$TMP_FOLDER/manifests" TMP_MANIFESTS_FOLDER="${TMP_FOLDER}/${K8S_NAMESPACE}/manifests" mkdir -p $TMP_MANIFESTS_FOLDER TMP_LOGS_FOLDER="$TMP_FOLDER/logs" TMP_LOGS_FOLDER="${TMP_FOLDER}/${K8S_NAMESPACE}/logs" mkdir -p $TMP_LOGS_FOLDER echo "Deleting and Creating a new namespace..." kubectl delete namespace $K8S_NAMESPACE kubectl delete namespace $K8S_NAMESPACE --ignore-not-found kubectl create namespace $K8S_NAMESPACE printf "\n" echo "Deploying components and collecting environment variables..." ENV_VARS_SCRIPT=tfs_bchain_runtime_env_vars.sh echo "# Environment variables for TeraFlow Mock-Blockchain deployment" > $ENV_VARS_SCRIPT echo "# Environment variables for TeraFlowSDN Mock-Blockchain deployment" > $ENV_VARS_SCRIPT PYTHONPATH=$(pwd)/src echo "export PYTHONPATH=${PYTHONPATH}" >> $ENV_VARS_SCRIPT echo "Processing '$COMPONENT' component..." IMAGE_NAME="$COMPONENT:$IMAGE_TAG" Loading @@ -77,12 +78,12 @@ cp ./manifests/"${COMPONENT}".yaml "$MANIFEST" if [ -n "$REGISTRY_IMAGE" ]; then # Registry is set VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4) sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" else # Registry is not set VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4) 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 Loading @@ -91,8 +92,8 @@ echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/deploy_${COMPONENT}.log" kubectl --namespace $K8S_NAMESPACE apply -f "$MANIFEST" > "$DEPLOY_LOG" COMPONENT_OBJNAME=$(echo "${COMPONENT}" | sed "s/\_/-/") kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=0 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=1 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" #kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=0 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" #kubectl --namespace $K8S_NAMESPACE scale deployment --replicas=1 ${COMPONENT_OBJNAME} >> "$DEPLOY_LOG" echo " Collecting env-vars for '$COMPONENT' component..." SERVICE_DATA=$(kubectl get service ${COMPONENT_OBJNAME} --namespace $K8S_NAMESPACE -o json) Loading
deploy/tfs.sh +1 −1 Original line number Diff line number Diff line Loading @@ -348,7 +348,7 @@ for COMPONENT in $TFS_COMPONENTS; do printf "\n" done if [[ "$TFS_COMPONENTS" == *"webui"* ]]; then if [[ "$TFS_COMPONENTS" == *"monitoring"* ]] && [[ "$TFS_COMPONENTS" == *"webui"* ]]; then echo "Configuring WebUI DataStores and Dashboards..." sleep 5 Loading
manifests/deviceservice.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ spec: exec: command: ["/bin/grpc_health_probe", "-addr=:2020"] failureThreshold: 30 periodSeconds: 10 periodSeconds: 1 readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:2020"] Loading
manifests/webuiservice.yaml +9 −8 Original line number Diff line number Diff line Loading @@ -74,26 +74,27 @@ spec: - name: GF_SERVER_SERVE_FROM_SUB_PATH value: "true" readinessProbe: failureThreshold: 3 failureThreshold: 60 httpGet: path: /robots.txt #path: /robots.txt path: /login port: 3000 scheme: HTTP initialDelaySeconds: 10 periodSeconds: 30 initialDelaySeconds: 1 periodSeconds: 1 successThreshold: 1 timeoutSeconds: 2 livenessProbe: failureThreshold: 3 initialDelaySeconds: 30 periodSeconds: 10 failureThreshold: 60 initialDelaySeconds: 1 periodSeconds: 1 successThreshold: 1 tcpSocket: port: 3000 timeoutSeconds: 1 resources: requests: cpu: 150m cpu: 250m memory: 512Mi limits: cpu: 500m Loading
src/common/message_broker/backend/nats/NatsBackendThread.py +21 −17 Original line number Diff line number Diff line Loading @@ -52,9 +52,11 @@ class NatsBackendThread(threading.Thread): self, topic_name : str, timeout : float, out_queue : queue.Queue[Message], unsubscribe : threading.Event, ready_event : threading.Event ) -> None: try: LOGGER.info('[_run_subscriber] NATS URI: {:s}'.format(str(self._nats_uri))) client = await nats.connect(servers=[self._nats_uri]) LOGGER.info('[_run_subscriber] Connected!') server_version = client.connected_server_version LOGGER.info('[_run_subscriber] Connected! NATS Server version: {:s}'.format(str(repr(server_version)))) subscription = await client.subscribe(topic_name) LOGGER.info('[_run_subscriber] Subscribed!') ready_event.set() Loading @@ -68,6 +70,8 @@ class NatsBackendThread(threading.Thread): out_queue.put(Message(message.subject, message.data.decode('UTF-8'))) await subscription.unsubscribe() await client.drain() except Exception: # pylint: disable=broad-exception-caught LOGGER.exception('[_run_subscriber] Unhandled Exception') def subscribe( self, topic_name : str, timeout : float, out_queue : queue.Queue[Message], unsubscribe : threading.Event Loading @@ -79,7 +83,7 @@ class NatsBackendThread(threading.Thread): self._tasks.append(task) LOGGER.info('[subscribe] Waiting for subscriber to be ready...') is_ready = ready_event.wait(timeout=120) LOGGER.info('[subscribe] Subscriber Ready: {:s}'.format(str(is_ready))) LOGGER.info('[subscribe] Subscriber is Ready? {:s}'.format(str(is_ready))) def run(self) -> None: asyncio.set_event_loop(self._event_loop) Loading