Skip to content

Commit

Permalink
[Imageprovider] Create Nginx service to host images, add instrumentat…
Browse files Browse the repository at this point in the history
…ion to it

Signed-off-by: krisztian.klucsik <[email protected]>
  • Loading branch information
klucsik committed Mar 15, 2024
1 parent 45feab5 commit cb48141
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ the release.
([#1449](https://github.com/open-telemetry/opentelemetry-demo/pull/1449))
* [Frontend-proxy] Add restart policy to compose file
([#1448](https://github.com/open-telemetry/opentelemetry-demo/pull/1448))
* [Imageprovider] Create Nginx service to host images, add instrumentation to it
([#1462](https://github.com/open-telemetry/opentelemetry-demo/pull/1462))

## 1.8.0

Expand Down
30 changes: 30 additions & 0 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ services:
condition: service_started
otelcol:
condition: service_started
imageprovider:
condition: service_started
logging: *logging

# Frontend Proxy (Envoy)
Expand Down Expand Up @@ -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
Expand All @@ -271,6 +275,32 @@ 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
depends_on:
otelcol:
condition: service_started
logging: *logging

# Load Generator
loadgenerator:
image: ${IMAGE_NAME}:${DEMO_VERSION}-loadgenerator
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ services:
condition: service_started
otelcol:
condition: service_started
imageprovider:
condition: service_started
logging: *logging

# Frontend Proxy (Envoy)
Expand Down Expand Up @@ -327,6 +329,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
Expand All @@ -341,6 +345,32 @@ 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
depends_on:
otelcol:
condition: service_started
logging: *logging

# Load Generator
loadgenerator:
image: ${IMAGE_NAME}:${DEMO_VERSION}-loadgenerator
Expand Down
14 changes: 14 additions & 0 deletions src/frontendproxy/envoy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -95,6 +97,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
Expand Down
23 changes: 23 additions & 0 deletions src/imageprovider/Dockerfile
Original file line number Diff line number Diff line change
@@ -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;'"]
31 changes: 31 additions & 0 deletions src/imageprovider/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 extract;
otel_service_name ${OTEL_SERVICE_NAME};


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;
}
}
File renamed without changes

0 comments on commit cb48141

Please sign in to comment.