Skip to content

Commit

Permalink
Update nginx-opentracing and jaeger-client-cpp (#1883)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatyRi authored Aug 25, 2021
1 parent 4fdf0d9 commit 9a0e69f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
29 changes: 24 additions & 5 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ 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

RUN apt-get update && apt-get install -y -q --fix-missing --no-install-recommends \
Expand All @@ -183,7 +183,7 @@ 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

WORKDIR /opentracing-cpp/.build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_STATIC_LIBS=OFF -DBUILD_MOCKTRACER=OFF -DENABLE_LINTING=OFF .. && \
Expand All @@ -195,6 +195,7 @@ RUN ./configure \
--add-dynamic-module=/nginx-opentracing/opentracing && \
make modules

WORKDIR /

############################################# Build image for Trace downloader #############################################
FROM debian AS tracer-downloader
Expand All @@ -205,14 +206,32 @@ 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

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/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

# If tracer version is avilable through tracer builder
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

Expand Down
2 changes: 1 addition & 1 deletion docs/content/technical-specifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}

Expand Down
18 changes: 12 additions & 6 deletions docs/content/third-party-modules/opentracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down

0 comments on commit 9a0e69f

Please sign in to comment.