diff --git a/.env b/.env index cf9ebdffc0..d2921c2d32 100644 --- a/.env +++ b/.env @@ -76,6 +76,10 @@ FRONTEND_HOST=frontend ENVOY_PORT=8080 FRONTEND_PROXY_ADDR=frontend-proxy:${ENVOY_PORT} +# Image Provider +IMAGE_PROVIDER_HOST=imageprovider +IMAGE_PROVIDER_PORT=8081 + # Load Generator LOCUST_WEB_PORT=8089 LOCUST_USERS=10 diff --git a/CHANGELOG.md b/CHANGELOG.md index 34abb054c5..fb0a4fc579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,8 @@ the release. ([#1470](https://github.com/open-telemetry/opentelemetry-demo/pull/1470)) * [frontend] disable instrumentation-fs library ([#1473](https://github.com/open-telemetry/opentelemetry-demo/pull/1473)) +* [Imageprovider] Create Nginx service to host images, add instrumentation to it + ([#1462](https://github.com/open-telemetry/opentelemetry-demo/pull/1462)) ## 1.8.0 diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index fb53948ecc..57698f32b9 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -228,6 +228,8 @@ services: condition: service_started otelcol: condition: service_started + imageprovider: + condition: service_started logging: *logging # Frontend Proxy (Envoy) @@ -256,6 +258,8 @@ services: - GRAFANA_SERVICE_HOST - JAEGER_SERVICE_PORT - JAEGER_SERVICE_HOST + - IMAGE_PROVIDER_HOST + - IMAGE_PROVIDER_PORT - OTEL_COLLECTOR_HOST - OTEL_COLLECTOR_PORT_GRPC - OTEL_COLLECTOR_PORT_HTTP @@ -271,6 +275,33 @@ services: grafana: condition: service_started + # Imageprovider + imageprovider: + image: ${IMAGE_NAME}:${DEMO_VERSION}-imageprovider + container_name: imageprovider + build: + context: ./ + dockerfile: ./src/imageprovider/Dockerfile + cache_from: + - ${IMAGE_NAME}:${IMAGE_VERSION}-imageprovider + deploy: + resources: + limits: + memory: 120M + restart: unless-stopped + ports: + - "${IMAGE_PROVIDER_PORT}" + environment: + - IMAGE_PROVIDER_PORT + - OTEL_COLLECTOR_HOST + - OTEL_COLLECTOR_PORT_GRPC + - OTEL_SERVICE_NAME=imageprovider + - OTEL_RESOURCE_ATTRIBUTES + depends_on: + otelcol: + condition: service_started + logging: *logging + # Load Generator loadgenerator: image: ${IMAGE_NAME}:${DEMO_VERSION}-loadgenerator diff --git a/docker-compose.yml b/docker-compose.yml index f724aea3a7..99672b8486 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -309,6 +309,8 @@ services: condition: service_started otelcol: condition: service_started + imageprovider: + condition: service_started logging: *logging # Frontend Proxy (Envoy) @@ -336,6 +338,8 @@ services: - JAEGER_SERVICE_PORT - JAEGER_SERVICE_HOST - OTEL_COLLECTOR_HOST + - IMAGE_PROVIDER_HOST + - IMAGE_PROVIDER_PORT - OTEL_COLLECTOR_PORT_GRPC - OTEL_COLLECTOR_PORT_HTTP - OTEL_RESOURCE_ATTRIBUTES @@ -350,6 +354,33 @@ services: grafana: condition: service_started + # Imageprovider + imageprovider: + image: ${IMAGE_NAME}:${DEMO_VERSION}-imageprovider + container_name: imageprovider + build: + context: ./ + dockerfile: ./src/imageprovider/Dockerfile + cache_from: + - ${IMAGE_NAME}:${IMAGE_VERSION}-imageprovider + deploy: + resources: + limits: + memory: 120M + restart: unless-stopped + ports: + - "${IMAGE_PROVIDER_PORT}" + environment: + - IMAGE_PROVIDER_PORT + - OTEL_COLLECTOR_HOST + - OTEL_COLLECTOR_PORT_GRPC + - OTEL_SERVICE_NAME=imageprovider + - OTEL_RESOURCE_ATTRIBUTES + depends_on: + otelcol: + condition: service_started + logging: *logging + # Load Generator loadgenerator: image: ${IMAGE_NAME}:${DEMO_VERSION}-loadgenerator diff --git a/src/frontendproxy/envoy.tmpl.yaml b/src/frontendproxy/envoy.tmpl.yaml index cb4dd0c8b3..163cd90468 100644 --- a/src/frontendproxy/envoy.tmpl.yaml +++ b/src/frontendproxy/envoy.tmpl.yaml @@ -45,6 +45,8 @@ static_resources: route: { cluster: jaeger } - match: { prefix: "/grafana" } route: { cluster: grafana } + - match: { prefix: "/images/" } + route: { cluster: imageprovider, prefix_rewrite: "/" } - match: { prefix: "/" } route: { cluster: frontend } http_filters: @@ -94,6 +96,18 @@ static_resources: socket_address: address: ${FRONTEND_HOST} port_value: ${FRONTEND_PORT} + - name: imageprovider + type: STRICT_DNS + lb_policy: ROUND_ROBIN + load_assignment: + cluster_name: imageprovider + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: ${IMAGE_PROVIDER_HOST} + port_value: ${IMAGE_PROVIDER_PORT} - name: loadgen type: STRICT_DNS lb_policy: ROUND_ROBIN diff --git a/src/imageprovider/Dockerfile b/src/imageprovider/Dockerfile new file mode 100644 index 0000000000..fbdbf38cb7 --- /dev/null +++ b/src/imageprovider/Dockerfile @@ -0,0 +1,23 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +FROM nginx:1.25.3 + +RUN apt-get update ; apt-get install lsb-release --no-install-recommends --no-install-suggests -y + +# This file is needed for nginx-module-otel to be found. +RUN echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" | tee /etc/apt/sources.list.d/nginx.list + +RUN apt-get update ; apt-get install nginx-module-otel --no-install-recommends --no-install-suggests -y + +RUN mkdir /static +COPY src/imageprovider/static /static + +EXPOSE ${IMAGE_PROVIDER_PORT} + +STOPSIGNAL SIGQUIT + +COPY src/imageprovider/nginx.conf.template /nginx.conf.template + +# Start nginx +CMD ["/bin/sh" , "-c" , "envsubst '$OTEL_COLLECTOR_HOST $IMAGE_PROVIDER_PORT $OTEL_COLLECTOR_PORT_GRPC $OTEL_SERVICE_NAME' < /nginx.conf.template > /etc/nginx/nginx.conf && cat /etc/nginx/nginx.conf && exec nginx -g 'daemon off;'"] diff --git a/src/imageprovider/nginx.conf.template b/src/imageprovider/nginx.conf.template new file mode 100644 index 0000000000..775b44a8c8 --- /dev/null +++ b/src/imageprovider/nginx.conf.template @@ -0,0 +1,32 @@ +load_module modules/ngx_otel_module.so; + +events { + worker_connections 1024; +} + +http { + otel_exporter { + endpoint ${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC}; + } + otel_trace on; + otel_trace_context propagate; + otel_service_name ${OTEL_SERVICE_NAME}; + otel_span_name imageprovider; + + + include mime.types; + sendfile on; + server { + listen ${IMAGE_PROVIDER_PORT}; + listen [::]:${IMAGE_PROVIDER_PORT}; + + resolver 127.0.0.11; + autoindex off; + + server_name _; + server_tokens off; + + root /static; + gzip_static on; + } +} diff --git a/src/frontend/public/images/Banner.png b/src/imageprovider/static/Banner.png similarity index 100% rename from src/frontend/public/images/Banner.png rename to src/imageprovider/static/Banner.png diff --git a/src/frontend/public/images/opentelemetry-demo-logo.png b/src/imageprovider/static/opentelemetry-demo-logo.png similarity index 100% rename from src/frontend/public/images/opentelemetry-demo-logo.png rename to src/imageprovider/static/opentelemetry-demo-logo.png diff --git a/src/frontend/public/images/products/EclipsmartTravelRefractorTelescope.jpg b/src/imageprovider/static/products/EclipsmartTravelRefractorTelescope.jpg similarity index 100% rename from src/frontend/public/images/products/EclipsmartTravelRefractorTelescope.jpg rename to src/imageprovider/static/products/EclipsmartTravelRefractorTelescope.jpg diff --git a/src/frontend/public/images/products/LensCleaningKit.jpg b/src/imageprovider/static/products/LensCleaningKit.jpg similarity index 100% rename from src/frontend/public/images/products/LensCleaningKit.jpg rename to src/imageprovider/static/products/LensCleaningKit.jpg diff --git a/src/frontend/public/images/products/NationalParkFoundationExplorascope.jpg b/src/imageprovider/static/products/NationalParkFoundationExplorascope.jpg similarity index 100% rename from src/frontend/public/images/products/NationalParkFoundationExplorascope.jpg rename to src/imageprovider/static/products/NationalParkFoundationExplorascope.jpg diff --git a/src/frontend/public/images/products/OpticalTubeAssembly.jpg b/src/imageprovider/static/products/OpticalTubeAssembly.jpg similarity index 100% rename from src/frontend/public/images/products/OpticalTubeAssembly.jpg rename to src/imageprovider/static/products/OpticalTubeAssembly.jpg diff --git a/src/frontend/public/images/products/RedFlashlight.jpg b/src/imageprovider/static/products/RedFlashlight.jpg similarity index 100% rename from src/frontend/public/images/products/RedFlashlight.jpg rename to src/imageprovider/static/products/RedFlashlight.jpg diff --git a/src/frontend/public/images/products/RoofBinoculars.jpg b/src/imageprovider/static/products/RoofBinoculars.jpg similarity index 100% rename from src/frontend/public/images/products/RoofBinoculars.jpg rename to src/imageprovider/static/products/RoofBinoculars.jpg diff --git a/src/frontend/public/images/products/SolarFilter.jpg b/src/imageprovider/static/products/SolarFilter.jpg similarity index 100% rename from src/frontend/public/images/products/SolarFilter.jpg rename to src/imageprovider/static/products/SolarFilter.jpg diff --git a/src/frontend/public/images/products/SolarSystemColorImager.jpg b/src/imageprovider/static/products/SolarSystemColorImager.jpg similarity index 100% rename from src/frontend/public/images/products/SolarSystemColorImager.jpg rename to src/imageprovider/static/products/SolarSystemColorImager.jpg diff --git a/src/frontend/public/images/products/StarsenseExplorer.jpg b/src/imageprovider/static/products/StarsenseExplorer.jpg similarity index 100% rename from src/frontend/public/images/products/StarsenseExplorer.jpg rename to src/imageprovider/static/products/StarsenseExplorer.jpg diff --git a/src/frontend/public/images/products/TheCometBook.jpg b/src/imageprovider/static/products/TheCometBook.jpg similarity index 100% rename from src/frontend/public/images/products/TheCometBook.jpg rename to src/imageprovider/static/products/TheCometBook.jpg