From 300339105d471f1c432a1085a3d6210acc75b968 Mon Sep 17 00:00:00 2001 From: Matyas Richter Date: Thu, 19 Aug 2021 11:29:06 +0200 Subject: [PATCH 1/5] Update Dockerfile Nginx Opentracing to 0.19.0 Docker opentracing build stage does not yield working image due to the Opentracing library version mismatch. Update Nginx Opentracing library from 0.10.0 to the latest available version of 0.19.0. Change also requires higher version of Jaeger Tracing module which can't be just downloaded (last available download is v0.4.2) and therefore build Jaeger Tracing module v0.7.0 as part of the opentracing-builder stage. Keep the plus version untouched. --- build/Dockerfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index f33de32b6e..f75cb1a0d8 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -155,8 +155,10 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode ############################################# Build image for Opentracing Builder ############################################# FROM debian as opentracing-builder -ARG NGINX_OPENTRACING=0.10.0 +ARG NGINX_OPENTRACING=0.19.0 ARG OPENTRACING_VERSION=1.6.0 +ARG JAEGER_VERSION=0.7.0 +# Jaeger version matched based on: https://github.com/opentracing-contrib/nginx-opentracing/blob/master/Dockerfile RUN apt-get update && apt-get install -y -q --fix-missing --no-install-recommends \ autoconf \ @@ -181,12 +183,19 @@ RUN apt-get update && apt-get install -y -q --fix-missing --no-install-recommend RUN curl -sS -O -L http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ && tar zxvf nginx-${NGINX_VERSION}.tar.gz && rm -f nginx-${NGINX_VERSION}.tar.gz \ && git clone --branch v${NGINX_OPENTRACING} https://github.com/opentracing-contrib/nginx-opentracing.git \ - && git clone --branch v${OPENTRACING_VERSION} https://github.com/opentracing/opentracing-cpp.git + && git clone --branch v${OPENTRACING_VERSION} https://github.com/opentracing/opentracing-cpp.git \ + && git clone --branch v${JAEGER_VERSION} https://github.com/jaegertracing/cpp-client.git WORKDIR /opentracing-cpp/.build RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_STATIC_LIBS=OFF -DBUILD_MOCKTRACER=OFF -DENABLE_LINTING=OFF .. && \ make && make install +WORKDIR /cpp-client/.build +RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DJAEGERTRACING_WITH_YAML_CPP=ON .. && \ + make && make install \ + && export HUNTER_INSTALL_DIR=$(cat _3rdParty/Hunter/install-root-dir) \ + && cp $HUNTER_INSTALL_DIR/lib/libyaml*so /usr/local/lib/ + WORKDIR /nginx-${NGINX_VERSION} RUN ./configure \ --with-compat --with-debug \ @@ -207,10 +216,12 @@ RUN apt-get update \ ############################################# Build image for Opentracing ############################################# FROM debian as opentracing ARG OPENTRACING_VERSION=1.6.0 +ARG JAEGER_VERSION=0.7.0 COPY --from=opentracing-builder /nginx-${NGINX_VERSION}/objs/ngx_http_opentracing_module.so /usr/lib/nginx/modules/ngx_http_opentracing_module.so COPY --from=opentracing-builder /usr/local/lib/libopentracing.so.${OPENTRACING_VERSION} /usr/local/lib/libopentracing.so.1 -COPY --from=tracer-downloader /usr/local/lib/libjaegertracing_plugin.so /usr/local/lib/libjaegertracing_plugin.so +COPY --from=opentracing-builder /usr/local/lib/libjaegertracing.so.${JAEGER_VERSION} /usr/local/lib/libjaegertracing_plugin.so +COPY --from=opentracing-builder /usr/local/lib/libyaml*so /usr/local/lib/ RUN ldconfig From 9fe807756e8d38adc0dd85a2cee6dc7bedfce6be Mon Sep 17 00:00:00 2001 From: Matyas Richter Date: Thu, 19 Aug 2021 13:02:03 +0200 Subject: [PATCH 2/5] Separate tracer builder from opentracing builder --- build/Dockerfile | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index f75cb1a0d8..89fb1a672e 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -157,8 +157,6 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode FROM debian as opentracing-builder ARG NGINX_OPENTRACING=0.19.0 ARG OPENTRACING_VERSION=1.6.0 -ARG JAEGER_VERSION=0.7.0 -# Jaeger version matched based on: https://github.com/opentracing-contrib/nginx-opentracing/blob/master/Dockerfile RUN apt-get update && apt-get install -y -q --fix-missing --no-install-recommends \ autoconf \ @@ -183,25 +181,19 @@ RUN apt-get update && apt-get install -y -q --fix-missing --no-install-recommend RUN curl -sS -O -L http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ && tar zxvf nginx-${NGINX_VERSION}.tar.gz && rm -f nginx-${NGINX_VERSION}.tar.gz \ && git clone --branch v${NGINX_OPENTRACING} https://github.com/opentracing-contrib/nginx-opentracing.git \ - && git clone --branch v${OPENTRACING_VERSION} https://github.com/opentracing/opentracing-cpp.git \ - && git clone --branch v${JAEGER_VERSION} https://github.com/jaegertracing/cpp-client.git + && git clone --branch v${OPENTRACING_VERSION} https://github.com/opentracing/opentracing-cpp.git WORKDIR /opentracing-cpp/.build RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_STATIC_LIBS=OFF -DBUILD_MOCKTRACER=OFF -DENABLE_LINTING=OFF .. && \ make && make install -WORKDIR /cpp-client/.build -RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DJAEGERTRACING_WITH_YAML_CPP=ON .. && \ - make && make install \ - && export HUNTER_INSTALL_DIR=$(cat _3rdParty/Hunter/install-root-dir) \ - && cp $HUNTER_INSTALL_DIR/lib/libyaml*so /usr/local/lib/ - WORKDIR /nginx-${NGINX_VERSION} RUN ./configure \ --with-compat --with-debug \ --add-dynamic-module=/nginx-opentracing/opentracing && \ make modules +WORKDIR / ############################################# Build image for Trace downloader ############################################# FROM debian AS tracer-downloader @@ -212,16 +204,34 @@ RUN apt-get update \ && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates apt-transport-https wget \ && wget -nv https://github.com/jaegertracing/jaeger-client-cpp/releases/download/${JAEGER_VERSION}/libjaegertracing_plugin.linux_amd64.so -O /usr/local/lib/libjaegertracing_plugin.so +############################################# Build image for Trace downloader ############################################# +FROM opentracing-builder AS tracer-builder + +ARG JAEGER_VERSION=0.7.0 +# Jaeger version matched based on: https://github.com/opentracing-contrib/nginx-opentracing/blob/master/Dockerfile + +RUN git clone --branch v${JAEGER_VERSION} https://github.com/jaegertracing/cpp-client.git + +WORKDIR /cpp-client/.build +RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DJAEGERTRACING_WITH_YAML_CPP=ON .. && \ + make && make install \ + && export HUNTER_INSTALL_DIR=$(cat _3rdParty/Hunter/install-root-dir) \ + && cp $HUNTER_INSTALL_DIR/lib/libyaml*so /usr/local/lib/ ############################################# Build image for Opentracing ############################################# FROM debian as opentracing ARG OPENTRACING_VERSION=1.6.0 -ARG JAEGER_VERSION=0.7.0 COPY --from=opentracing-builder /nginx-${NGINX_VERSION}/objs/ngx_http_opentracing_module.so /usr/lib/nginx/modules/ngx_http_opentracing_module.so COPY --from=opentracing-builder /usr/local/lib/libopentracing.so.${OPENTRACING_VERSION} /usr/local/lib/libopentracing.so.1 -COPY --from=opentracing-builder /usr/local/lib/libjaegertracing.so.${JAEGER_VERSION} /usr/local/lib/libjaegertracing_plugin.so -COPY --from=opentracing-builder /usr/local/lib/libyaml*so /usr/local/lib/ + +# If tracer version is available through tracer downloader +# COPY --from=tracer-downloader /usr/local/lib/libjaegertracing_plugin.so /usr/local/lib/libjaegertracing_plugin.so + +# If tracer version is avilable through tracer builder +ARG JAEGER_VERSION=0.7.0 +COPY --from=tracer-builder /usr/local/lib/libjaegertracing.so.${JAEGER_VERSION} /usr/local/lib/libjaegertracing_plugin.so +COPY --from=tracer-builder /usr/local/lib/libyaml*so /usr/local/lib/ RUN ldconfig From 1a16c23b634128655420107430f3e526e7322038 Mon Sep 17 00:00:00 2001 From: Matyas Richter Date: Thu, 19 Aug 2021 13:02:29 +0200 Subject: [PATCH 3/5] Update documentation for opentracing build --- docs/content/technical-specifications.md | 2 +- .../content/third-party-modules/opentracing.md | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/content/technical-specifications.md b/docs/content/technical-specifications.md index 7495771799..ecf8e56e08 100644 --- a/docs/content/technical-specifications.md +++ b/docs/content/technical-specifications.md @@ -29,7 +29,7 @@ The supported architecture is x86-64. | ---| ---| ---| --- | |Debian-based image | ``nginx:1.21.0``, which is based on ``debian:buster-slim`` | | ``nginx/nginx-ingress:1.12.0`` | |Alpine-based image | ``nginx:1.21.0-alpine``, which is based on ``alpine:3.13`` | | ``nginx/nginx-ingress:1.12.0-alpine`` | -|Debian-based image with Opentracing | ``nginx:1.21.0``, which is based on ``debian:buster-slim`` | OpenTracing API for C++ 1.5.1, NGINX plugin for OpenTracing, C++ OpenTracing binding for Jaeger 0.4.2 | | +|Debian-based image with Opentracing | ``nginx:1.21.0``, which is based on ``debian:buster-slim`` | OpenTracing API for C++ 1.6.0, NGINX plugin for OpenTracing 0.19.0, C++ OpenTracing binding for Jaeger 0.7.0 | | |Ubi-based image | ``registry.access.redhat.com/ubi8/ubi:8.3`` | | ``nginx/nginx-ingress:1.12.0-ubi`` | {{% /table %}} diff --git a/docs/content/third-party-modules/opentracing.md b/docs/content/third-party-modules/opentracing.md index b984b57ab4..6e199f178f 100644 --- a/docs/content/third-party-modules/opentracing.md +++ b/docs/content/third-party-modules/opentracing.md @@ -14,12 +14,17 @@ The Ingress Controller supports [OpenTracing](https://opentracing.io/) with the This document explains how to use OpenTracing with the Ingress Controller. ## Prerequisites -1. **Use the Ingress Controller image with OpenTracing.** The default Ingress Controller images don’t include the OpenTracing module. To use OpenTracing, you need to build the image with that module. Follow the build instructions to build the image using `openshift-image` for NGINX or `openshift-image-plus` for NGINX Plus. -By default, the Dockerfiles install Jaeger as a tracer. However, it is possible to replace Jaeger with other supported [tracers](https://github.com/opentracing-contrib/nginx-opentracing#building-from-source). For that, please modify the Dockerfile accordingly: - 1. Change the download line in the tracer-downloader stage of the Dockerfile to download the right tracer. - 1. Edit the COPY line of the final image to copy the previously downloaded tracer to the image - -1. **Load the OpenTracing module.** You need to load the module with the configuration for the chosen tracer using the following ConfigMap keys: +1. **Use the Ingress Controller image with OpenTracing.** The default Ingress Controller images don’t include the OpenTracing module. To use OpenTracing, you need to build the image with that module. Follow the build instructions to build the image using `debian-image-opentracing` for NGINX or `debian-image-opentracing-plus` for NGINX Plus. +By default, the Dockerfiles build & install Jaeger as a tracer. However, it is possible to replace Jaeger with other supported [tracers](https://github.com/opentracing-contrib/nginx-opentracing#building-from-source). For that, please modify the Dockerfile accordingly: + 1. Find out which version of supported tracer you will need based on the current OpenTracing C++ API + 2. If direct download of that version is avilable: + 1. Change the download line in the `tracer-downloader` stage of the Dockerfile to download the right tracer. + 2. Edit the COPY line of the final image to copy the previously downloaded tracer to the image + 2. If tracer needs to be built: + 1. Change the content the `tracer-builder` stage of the Dockerfile to build the right tracer. Build steps can be found in [Nginx Opentracing Dockerfile](https://github.com/opentracing-contrib/nginx-opentracing/blob/master/Dockerfile) + 2. Edit the COPY line of the final image to copy the previously built tracer to the image + +2. **Load the OpenTracing module.** You need to load the module with the configuration for the chosen tracer using the following ConfigMap keys: * `opentracing-tracer`: sets the path to the vendor tracer binary plugin. This is the path you used in the COPY line of step *ii* above. * `opentracing-tracer-config`: sets the tracer configuration in JSON format. @@ -29,6 +34,7 @@ By default, the Dockerfiles install Jaeger as a tracer. However, it is possible opentracing-tracer-config: | { "service_name": "nginx-ingress", + "propagation_format": "w3c", "sampler": { "type": "const", "param": 1 From 0549d82ad046abe08bb267d0ad2624808b39e7f9 Mon Sep 17 00:00:00 2001 From: Matyas Richter Date: Wed, 25 Aug 2021 23:53:21 +0200 Subject: [PATCH 4/5] Remove JAEGER_VERSION from opentracing build stage Co-authored-by: Luca Comellini --- build/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index ac605dfca3..4f25a972fb 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -229,8 +229,7 @@ COPY --from=opentracing-builder /usr/local/lib/libopentracing.so.${OPENTRACING_V # COPY --from=tracer-downloader /usr/local/lib/libjaegertracing_plugin.so /usr/local/lib/libjaegertracing_plugin.so # If tracer version is avilable through tracer builder -ARG JAEGER_VERSION=0.7.0 -COPY --from=tracer-builder /usr/local/lib/libjaegertracing.so.${JAEGER_VERSION} /usr/local/lib/libjaegertracing_plugin.so +COPY --from=tracer-builder /usr/local/lib/libjaegertracing.so.* /usr/local/lib/libjaegertracing_plugin.so COPY --from=tracer-builder /usr/local/lib/libyaml*so /usr/local/lib/ RUN ldconfig From 7058efd26c22f6702a1da96ef26bf9e06de3b2e1 Mon Sep 17 00:00:00 2001 From: Matyas Richter Date: Thu, 26 Aug 2021 00:03:42 +0200 Subject: [PATCH 5/5] Remove redundant opentracing version declaration --- build/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index a2162adc6f..b7bcd996c9 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -222,10 +222,9 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DJAEGERTRACING_WITH_YA ############################################# Build image for Opentracing ############################################# FROM debian as opentracing -ARG OPENTRACING_VERSION=1.6.0 COPY --from=opentracing-builder /nginx-${NGINX_VERSION}/objs/ngx_http_opentracing_module.so /usr/lib/nginx/modules/ngx_http_opentracing_module.so -COPY --from=opentracing-builder /usr/local/lib/libopentracing.so.${OPENTRACING_VERSION} /usr/local/lib/libopentracing.so.1 +COPY --from=opentracing-builder /usr/local/lib/libopentracing.so.* /usr/local/lib/libopentracing.so.1 # If tracer version is available through tracer downloader # COPY --from=tracer-downloader /usr/local/lib/libjaegertracing_plugin.so /usr/local/lib/libjaegertracing_plugin.so