From b0da3d3cf171465034ae872712b60977deff657d Mon Sep 17 00:00:00 2001 From: Brian McGinn Date: Fri, 2 Aug 2024 14:46:11 -0700 Subject: [PATCH] fix: pipeline-server version to use Docker network for more consistent container connnections --------- Signed-off-by: Brian McGinn --- Makefile | 4 +- helm/Dockerfile.cam-sim | 12 --- helm/Makefile | 10 +-- helm/docker-compose.yml | 24 +++--- helm/kubernetes.md | 2 - helm/swarm.md | 4 +- src/docker-compose.yml | 8 +- .../docker-compose.pipeline-server.yml | 58 +++++++++++--- src/pipeline-server/postman/env.json | 6 -- src/pipeline-server/postman/pipeline.json | 76 +++++++++++++++---- src/pipeline-server/run-pipelines.sh | 12 +++ 11 files changed, 147 insertions(+), 69 deletions(-) delete mode 100644 helm/Dockerfile.cam-sim create mode 100755 src/pipeline-server/run-pipelines.sh diff --git a/Makefile b/Makefile index b9509f05..4580c895 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ build: build-realsense: docker build --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} --target build-realsense -t dlstreamer:realsense -f src/Dockerfile src/ -build-pipeline-server: +build-pipeline-server: | download-models update-submodules download-sample-videos docker build --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -t dlstreamer:pipeline-server -f src/pipeline-server/Dockerfile.pipeline-server src/pipeline-server run: @@ -63,7 +63,7 @@ run-headless: | download-models update-submodules download-sample-videos @echo Running automated self checkout pipeline $(MAKE) run -run-pipeline-server: | download-models update-submodules download-sample-videos build-pipeline-server +run-pipeline-server: | build-pipeline-server RETAIL_USE_CASE_ROOT=$(RETAIL_USE_CASE_ROOT) docker compose -f src/pipeline-server/docker-compose.pipeline-server.yml up -d down-pipeline-server: diff --git a/helm/Dockerfile.cam-sim b/helm/Dockerfile.cam-sim deleted file mode 100644 index 8947e85c..00000000 --- a/helm/Dockerfile.cam-sim +++ /dev/null @@ -1,12 +0,0 @@ -# -# Copyright (C) 2024 Intel Corporation. -# -# SPDX-License-Identifier: Apache-2.0 -# - -FROM openvino/ubuntu20_data_runtime:2021.4.2 - -USER root -RUN apt-get update && apt-get install --no-install-recommends -y wget - -RUN mkdir -p /sample-media && wget -O /sample-media/00-coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029/ \ No newline at end of file diff --git a/helm/Makefile b/helm/Makefile index c63e2134..72c73ed0 100644 --- a/helm/Makefile +++ b/helm/Makefile @@ -1,20 +1,14 @@ # Copyright © 2024 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -.PHONY: build build-cam-sim build-all build-minikube run-minikube-demo stop-minikube-demo helm-convert install-helm uninstall-helm +.PHONY: build build-all build-minikube run-minikube-demo stop-minikube-demo helm-convert install-helm uninstall-helm build: docker build --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -t dlstreamer:deploy -f Dockerfile .. -build-cam-sim: - docker build --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -t cam-sim:dev -f Dockerfile.cam-sim . - -build-all : build build-cam-sim - -build-minikube: build-all +build-minikube: build minikube start minikube image build -t dlstreamer:deploy -f helm/Dockerfile .. - minikube image build -t cam-sim:dev -f Dockerfile.cam-sim . run-minikube-demo: build-minikube kompose -f docker-compose.yml convert -o kubernetes/ && \ diff --git a/helm/docker-compose.yml b/helm/docker-compose.yml index 1d2e95b7..6dd20340 100644 --- a/helm/docker-compose.yml +++ b/helm/docker-compose.yml @@ -14,21 +14,21 @@ services: ports: - "8554:8554" camera-simulator0: - image: cam-sim:dev + image: jrottenberg/ffmpeg:4.1-alpine container_name: camera-simulator0 - entrypoint: ffmpeg - command: " - -nostdin - -re -stream_loop -1 - -i /sample-media/00-coca-cola-4465029-1920-15-bench.mp4 - -c copy - -f rtsp - -rtsp_transport - tcp - rtsp://camera-simulator:8554/camera_0 - " + entrypoint: ["/bin/sh","-c"] + command: + - | + if [ ! -f /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 ]; then + mkdir -p /home/pipeline-server/sample-media + wget -O /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029 + fi + ffmpeg -nostdin -re -stream_loop -1 -i /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport tcp rtsp://camera-simulator:8554/camera_0 depends_on: - camera-simulator + volumes: + - ${RETAIL_USE_CASE_ROOT:-..}/performance-tools/sample-media:/home/pipeline-server/sample-media + dlstreamer: image: dlstreamer:deploy deploy: diff --git a/helm/kubernetes.md b/helm/kubernetes.md index 66726b3c..540e0d1a 100644 --- a/helm/kubernetes.md +++ b/helm/kubernetes.md @@ -93,7 +93,6 @@ kubelet: Running For a multinode setup, we need to load the local docker images to all nodes. ``` -minikube image load cam-sim:dev minikube image load dlstreamer:deploy ``` @@ -172,7 +171,6 @@ minikube start --nodes 2 -p multinode You can try these commands to load the images instead of the **minikube load** ``` -minikube cache add cam-sim:dev minikube cache add dlstreamer:deploy ``` diff --git a/helm/swarm.md b/helm/swarm.md index a8480d58..5b07c6bd 100644 --- a/helm/swarm.md +++ b/helm/swarm.md @@ -9,7 +9,7 @@ This document guides you to deploy a cluster using docker swarm with physical no ## Build docker images on all nodes -Ensure that **cam-sim:dev** and **dlstreamer:deploy** docker images are built on every node. +Ensure that **dlstreamer:deploy** docker images are built on every node. You can transfer the docker images to the other nodes or you can clone and run this command on every node to ensure the images are available. ``` @@ -83,7 +83,7 @@ Output: | ID | NAME | MODE | REPLICAS | IMAGE | PORTS | |----------------|------------------------------|-------------|----------|------------------------------------|--------------------| | sadfdsfdsfdd | checkout_camera-simulator | replicated | 1/1 | aler9/rtsp-simple-server:latest | *:8554->8554/tcp | -| sdfsdfsdfdsf | checkout_camera-simulator0 | replicated | 1/1 | cam-sim:dev | | +| sdfsdfsdfdsf | checkout_camera-simulator0 | replicated | 1/1 | jrottenberg/ffmpeg:4.1-alpine | | | dsfewfdesfdf | checkout_dlstreamer | replicated | 1/1 | dlstreamer:deploy | | ### Scale dlstreamer container diff --git a/src/docker-compose.yml b/src/docker-compose.yml index ab33e29d..4e9bb0d7 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -20,11 +20,15 @@ services: entrypoint: ["/bin/sh","-c"] command: - | - mkdir -p /home/pipeline-server/sample-media - wget -O /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029 + if [ ! -f /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 ]; then + mkdir -p /home/pipeline-server/sample-media + wget -O /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029 + fi ffmpeg -nostdin -re -stream_loop -1 -i /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport tcp rtsp://localhost:8554/camera_0 depends_on: - camera-simulator + volumes: + - ${RETAIL_USE_CASE_ROOT:-..}/performance-tools/sample-media:/home/pipeline-server/sample-media OvmsClientGst: image: dlstreamer:dev diff --git a/src/pipeline-server/docker-compose.pipeline-server.yml b/src/pipeline-server/docker-compose.pipeline-server.yml index f16921a9..0e14083a 100644 --- a/src/pipeline-server/docker-compose.pipeline-server.yml +++ b/src/pipeline-server/docker-compose.pipeline-server.yml @@ -7,28 +7,43 @@ ## Current Developer Toolbox doesn't support environment files, make sure to remove any files or environment variables starting with $ version: '3.7' +networks: + checkout-network: + driver: bridge services: camera-simulator: container_name: camera-simulator image: aler9/rtsp-simple-server ports: - "8554:8554" + environment: + - http_proxy= + - https_proxy= + - HTTP_PROXY= + - HTTPS_PROXY= + networks: + checkout-network: {} camera-simulator0: image: jrottenberg/ffmpeg:4.1-alpine container_name: camera-simulator0 - network_mode: "host" entrypoint: ["/bin/sh","-c"] command: - | - mkdir -p /home/pipeline-server/sample-media - wget -O /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029 - ffmpeg -nostdin -re -stream_loop -1 -i /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport tcp rtsp://localhost:8554/camera_0 + if [ ! -f /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 ]; then + mkdir -p /home/pipeline-server/sample-media + wget -O /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 https://www.pexels.com/download/video/4465029 + fi + ffmpeg -nostdin -re -stream_loop -1 -i /home/pipeline-server/sample-media/coca-cola-4465029-1920-15-bench.mp4 -c copy -f rtsp -rtsp_transport tcp rtsp://camera-simulator:8554/camera_0 depends_on: - camera-simulator + volumes: + - ${RETAIL_USE_CASE_ROOT:-..}/performance-tools/sample-media:/home/pipeline-server/sample-media + networks: + checkout-network: {} evamclient0: container_name: evam_0 - image: intel/dlstreamer-pipeline-server:2022.2.0-ubuntu20-gpu419.40 + image: dlstreamer:pipeline-server ports: - 8555:8554 - 8080:8080 @@ -40,15 +55,21 @@ services: - RUN_MODE=EVA - DETECTION_DEVICE=CPU - CLASSIFICATION_DEVICE=CPU + - http_proxy= + - https_proxy= + - HTTP_PROXY= + - HTTPS_PROXY= volumes: - ${RETAIL_USE_CASE_ROOT:-..}/src/extensions:/home/pipeline-server/gvapython - ${RETAIL_USE_CASE_ROOT:-../..}/models:/home/pipeline-server/models - ${RETAIL_USE_CASE_ROOT:-..}/src/pipeline-server/asc:/home/pipeline-server/pipelines - "${RETAIL_USE_CASE_ROOT:-..}/src/pipeline-server/config.json:/home/pipeline-server/config.json" + networks: + checkout-network: {} evamclient1: container_name: evam_1 - image: intel/dlstreamer-pipeline-server:2022.2.0-ubuntu20-gpu419.40 + image: dlstreamer:pipeline-server ports: - 8556:8554 - 8081:8080 @@ -60,15 +81,21 @@ services: - RUN_MODE=EVA - DETECTION_DEVICE=CPU - CLASSIFICATION_DEVICE=CPU + - http_proxy= + - https_proxy= + - HTTP_PROXY= + - HTTPS_PROXY= volumes: - ${RETAIL_USE_CASE_ROOT:-..}/src/extensions:/home/pipeline-server/gvapython - ${RETAIL_USE_CASE_ROOT:-../..}/models:/home/pipeline-server/models - ${RETAIL_USE_CASE_ROOT:-..}/src/pipeline-server/asc:/home/pipeline-server/pipelines - "${RETAIL_USE_CASE_ROOT:-..}/src/pipeline-server/config.json:/home/pipeline-server/config.json" + networks: + checkout-network: {} evamclient2: container_name: evam_2 - image: intel/dlstreamer-pipeline-server:2022.2.0-ubuntu20-gpu419.40 + image: dlstreamer:pipeline-server ports: - 8557:8554 - 8082:8080 @@ -80,19 +107,30 @@ services: - RUN_MODE=EVA - DETECTION_DEVICE=CPU - CLASSIFICATION_DEVICE=CPU + - http_proxy= + - https_proxy= + - HTTP_PROXY= + - HTTPS_PROXY= volumes: - ${RETAIL_USE_CASE_ROOT:-..}/src/extensions:/home/pipeline-server/gvapython - ${RETAIL_USE_CASE_ROOT:-../..}/models:/home/pipeline-server/models - ${RETAIL_USE_CASE_ROOT:-..}/src/pipeline-server/asc:/home/pipeline-server/pipelines - "${RETAIL_USE_CASE_ROOT:-..}/src/pipeline-server/config.json:/home/pipeline-server/config.json" + networks: + checkout-network: {} pipeline-init: image: postman/newman command: run /postman/pipeline.json -e "/postman/env.json" --verbose environment: - - LOCAL_IP=192.168.1.140 + - http_proxy= + - https_proxy= + - HTTP_PROXY= + - HTTPS_PROXY= volumes: - ./postman/:/postman + networks: + checkout-network: {} mqtt-broker: command: @@ -112,4 +150,6 @@ services: restart: always security_opt: - no-new-privileges:true - user: 2002:2001 \ No newline at end of file + user: 2002:2001 + networks: + checkout-network: {} \ No newline at end of file diff --git a/src/pipeline-server/postman/env.json b/src/pipeline-server/postman/env.json index 8220b963..13e65a18 100644 --- a/src/pipeline-server/postman/env.json +++ b/src/pipeline-server/postman/env.json @@ -2,12 +2,6 @@ "id": "773fe33a-1231-4703-af91-e5cb72e6fcb4", "name": "Pipeline Environment", "values": [ - { - "key": "host", - "value": "192.168.1.140", - "type": "default", - "enabled": true - }, { "key": "pipeline", "value": "yolov5", diff --git a/src/pipeline-server/postman/pipeline.json b/src/pipeline-server/postman/pipeline.json index 27884792..5b89a411 100644 --- a/src/pipeline-server/postman/pipeline.json +++ b/src/pipeline-server/postman/pipeline.json @@ -27,10 +27,26 @@ ], "request": { "method": "POST", - "header": [], + "header": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*", + "type": "text" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "POST, GET, OPTIONS, PUT, DELETE", + "type": "text" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, X-CSRF-Token", + "type": "text" + } + ], "body": { "mode": "raw", - "raw": "{\n \"source\": {\n \"uri\": \"rtsp://{{host}}:8554/camera_0\",\n \"type\": \"uri\"\n },\n \"destination\": {\n \"metadata\": {\n \"type\": \"mqtt\",\n \"host\": \"mqtt-broker:1883\",\n \"topic\": \"AnalyticsData0\",\n \"timeout\": 1000\n }\n },\n \"parameters\": {\n \"detection-device\": \"CPU\"\n }\n }", + "raw": "{\n \"source\": {\n \"uri\": \"rtsp://camera-simulator:8554/camera_0\",\n \"type\": \"uri\"\n },\n \"destination\": {\n \"metadata\": {\n \"type\": \"mqtt\",\n \"host\": \"mqtt-broker:1883\",\n \"topic\": \"AnalyticsData0\",\n \"timeout\": 1000\n }\n },\n \"parameters\": {\n \"detection-device\": \"CPU\"\n }\n }", "options": { "raw": { "language": "json" @@ -38,9 +54,9 @@ } }, "url": { - "raw": "{{host}}:8080/pipelines/detection/{{pipeline}}", + "raw": "evam_0:8080/pipelines/detection/{{pipeline}}", "host": [ - "{{host}}" + "evam_0" ], "port": "8080", "path": [ @@ -73,10 +89,26 @@ ], "request": { "method": "POST", - "header": [], + "header": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*", + "type": "text" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "POST, GET, OPTIONS, PUT, DELETE", + "type": "text" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, X-CSRF-Token", + "type": "text" + } + ], "body": { "mode": "raw", - "raw": "{\n \"source\": {\n \"uri\": \"rtsp://{{host}}:8554/camera_0\",\n \"type\": \"uri\"\n },\n \"destination\": {\n \"metadata\": {\n \"type\": \"mqtt\",\n \"host\": \"mqtt-broker:1883\",\n \"topic\": \"AnalyticsData1\",\n \"timeout\": 1000\n }\n },\n \"parameters\": {\n \"detection-device\": \"CPU\"\n }\n }", + "raw": "{\n \"source\": {\n \"uri\": \"rtsp://camera-simulator:8554/camera_0\",\n \"type\": \"uri\"\n },\n \"destination\": {\n \"metadata\": {\n \"type\": \"mqtt\",\n \"host\": \"mqtt-broker:1883\",\n \"topic\": \"AnalyticsData1\",\n \"timeout\": 1000\n }\n },\n \"parameters\": {\n \"detection-device\": \"CPU\"\n }\n }", "options": { "raw": { "language": "json" @@ -84,11 +116,11 @@ } }, "url": { - "raw": "{{host}}:8081/pipelines/detection/{{pipeline}}", + "raw": "evam_1:8080/pipelines/detection/{{pipeline}}", "host": [ - "{{host}}" + "evam_1" ], - "port": "8081", + "port": "8080", "path": [ "pipelines", "detection", @@ -119,10 +151,26 @@ ], "request": { "method": "POST", - "header": [], + "header": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*", + "type": "text" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "POST, GET, OPTIONS, PUT, DELETE", + "type": "text" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, X-CSRF-Token", + "type": "text" + } + ], "body": { "mode": "raw", - "raw": "{\n \"source\": {\n \"uri\": \"rtsp://{{host}}:8554/camera_0\",\n \"type\": \"uri\"\n },\n \"destination\": {\n \"metadata\": {\n \"type\": \"mqtt\",\n \"host\": \"mqtt-broker:1883\",\n \"topic\": \"AnalyticsData2\",\n \"timeout\": 1000\n }\n },\n \"parameters\": {\n \"detection-device\": \"CPU\"\n }\n }", + "raw": "{\n \"source\": {\n \"uri\": \"rtsp://camera-simulator:8554/camera_0\",\n \"type\": \"uri\"\n },\n \"destination\": {\n \"metadata\": {\n \"type\": \"mqtt\",\n \"host\": \"mqtt-broker:1883\",\n \"topic\": \"AnalyticsData2\",\n \"timeout\": 1000\n }\n },\n \"parameters\": {\n \"detection-device\": \"CPU\"\n }\n }", "options": { "raw": { "language": "json" @@ -130,11 +178,11 @@ } }, "url": { - "raw": "{{host}}:8082/pipelines/detection/{{pipeline}}", + "raw": "evam_2:8080/pipelines/detection/{{pipeline}}", "host": [ - "{{host}}" + "evam_2" ], - "port": "8082", + "port": "8080", "path": [ "pipelines", "detection", diff --git a/src/pipeline-server/run-pipelines.sh b/src/pipeline-server/run-pipelines.sh new file mode 100755 index 00000000..0e0d8b7b --- /dev/null +++ b/src/pipeline-server/run-pipelines.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# Copyright (C) 2024 Intel Corporation. +# +# SPDX-License-Identifier: Apache-2.0 +# + +host=$1 + +curl 'localhost:8080/pipelines/detection/yolov5' --header 'Content-Type: application/json' --data '{"source": {"uri": "rtsp://'$host':8554/camera_0","type": "uri"},"destination": {"metadata": {"type": "mqtt","host": "mqtt-broker:1883","topic": "AnalyticsData0","timeout": 1000}},"parameters": {"detection-device": "CPU"}}' +curl 'localhost:8081/pipelines/detection/yolov5' --header 'Content-Type: application/json' --data '{"source": {"uri": "rtsp://'$host':8554/camera_0","type": "uri"},"destination": {"metadata": {"type": "mqtt","host": "mqtt-broker:1883","topic": "AnalyticsData1","timeout": 1000}},"parameters": {"detection-device": "CPU"}}' +curl 'localhost:8082/pipelines/detection/yolov5' --header 'Content-Type: application/json' --data '{"source": {"uri": "rtsp://'$host':8554/camera_0","type": "uri"},"destination": {"metadata": {"type": "mqtt","host": "mqtt-broker:1883","topic": "AnalyticsData2","timeout": 1000}},"parameters": {"detection-device": "CPU"}}'