ingress-nginx-helm/user-guide/third-party-addons/opentracing/index.html

167 lines
31 KiB
HTML
Raw Normal View History

2021-05-23 16:14:37 +00:00
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href=https://kubernetes.github.io/ingress-nginx/user-guide/third-party-addons/opentracing/ rel=canonical><link rel="shortcut icon" href=../../../assets/images/favicon.png><meta name=generator content="mkdocs-1.1.2, mkdocs-material-6.2.4"><title>OpenTracing - NGINX Ingress Controller</title><link rel=stylesheet href=../../../assets/stylesheets/main.15aa0b43.min.css><link rel=stylesheet href=../../../assets/stylesheets/palette.75751829.min.css><meta name=theme-color content=#009485><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback"><style>body,input{font-family:"Roboto",-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono",SFMono-Regular,Consolas,Menlo,monospace}</style><link rel=stylesheet href=../../../extra.css><script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-118407822-1","kubernetes.github.io"),ga("set","anonymizeIp",!0),ga("send","pageview"),document.addEventListener("DOMContentLoaded",function(){document.forms.search&&document.forms.search.query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})}),document.addEventListener("DOMContentSwitch",function(){ga("send","pageview",document.location.pathname)})</script><script async src=https://www.google-analytics.com/analytics.js></script></head> <body dir=ltr data-md-color-scheme data-md-color-primary=teal data-md-color-accent=green> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#opentracing class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header-nav md-grid" aria-label=Header> <a href=https://kubernetes.github.io/ingress-nginx title="NGINX Ingress Controller" class="md-header-nav__button md-logo" aria-label="NGINX Ingress Controller"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 003-3 3 3 0 00-3-3 3 3 0 00-3 3 3 3 0 003 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z"/></svg> </a> <label class="md-header-nav__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg> </label> <div class=md-header-nav__title data-md-component=header-title> <div class=md-header-nav__ellipsis> <div class=md-header-nav__topic> <span class=md-ellipsis> NGINX Ingress Controller </span> </div> <div class=md-header-nav__topic> <span class=md-ellipsis> OpenTracing </span> </div> </div> </div> <label class="md-header-nav__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg> </label> <div class=md-search data-md-component=search role=dialog> <label class=md-search__overlay for=__search></label> <div class=md-search__inner role=search> <form class=md-search__form name=search> <input type=text class=md-search__input name=query aria-label=Search placeholder=Search autocapitalize=off autocorrect=off autocomplete=off spellcheck=false data-md-component=search-query data-md-state=active required> <label class="md-search__icon md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0
2020-04-15 17:09:38 +00:00
enable-opentracing: &quot;true&quot;
2021-01-11 15:59:14 +00:00
</code></pre></div></p> <p>To enable or disable instrumentation for a single Ingress, use the <code>enable-opentracing</code> annotation: <div class=highlight><pre><span></span><code>kind: Ingress
2020-04-15 17:09:38 +00:00
metadata:
annotations:
nginx.ingress.kubernetes.io/enable-opentracing: &quot;true&quot;
2021-01-11 15:59:14 +00:00
</code></pre></div></p> <p>We must also set the host to use when uploading traces:</p> <p><div class=highlight><pre><span></span><code>zipkin-collector-host: zipkin.default.svc.cluster.local
2020-04-15 17:09:38 +00:00
jaeger-collector-host: jaeger-agent.default.svc.cluster.local
datadog-collector-host: datadog-agent.default.svc.cluster.local
2021-03-09 19:00:11 +00:00
</code></pre></div> NOTE: While the option is called <code>jaeger-collector-host</code>, you will need to point this to a <code>jaeger-agent</code>, and not the <code>jaeger-collector</code> component. Alternatively, you can set <code>jaeger-endpoint</code> and specify the full endpoint for uploading traces. This will use TCP and should be used for a collector rather than an agent.</p> <p>Next you will need to deploy a distributed tracing system which uses OpenTracing. <a href=https://github.com/openzipkin/zipkin>Zipkin</a> and <a href=https://github.com/jaegertracing/jaeger>Jaeger</a> and <a href=https://github.com/DataDog/dd-opentracing-cpp>Datadog</a> have been tested.</p> <p>Other optional configuration options: <div class=highlight><pre><span></span><code># specifies the name to use for the server span
2020-07-24 15:08:44 +00:00
opentracing-operation-name
# specifies specifies the name to use for the location span
opentracing-location-operation-name
# specifies the port to use when uploading traces, Default: 9411
2020-04-15 17:09:38 +00:00
zipkin-collector-port
2018-06-24 15:16:34 +00:00
2020-04-15 17:09:38 +00:00
# specifies the service name to use for any traces created, Default: nginx
zipkin-service-name
2018-06-24 15:16:34 +00:00
2020-04-15 17:09:38 +00:00
# specifies sample rate for any traces created, Default: 1.0
zipkin-sample-rate
2018-07-03 03:39:29 +00:00
2020-04-15 17:09:38 +00:00
# specifies the port to use when uploading traces, Default: 6831
jaeger-collector-port
2018-06-24 15:16:34 +00:00
2021-03-09 19:00:11 +00:00
# specifies the endpoint to use when uploading traces to a collector instead of an agent
jaeger-endpoint
2020-04-15 17:09:38 +00:00
# specifies the service name to use for any traces created, Default: nginx
jaeger-service-name
2018-06-24 15:16:34 +00:00
2021-03-26 17:33:56 +00:00
# specifies the traceparent/tracestate propagation format
jaeger-propagation-format
2020-04-15 17:09:38 +00:00
# specifies the sampler to be used when sampling traces.
# The available samplers are: const, probabilistic, ratelimiting, remote, Default: const
jaeger-sampler-type
2018-06-24 15:16:34 +00:00
2020-04-15 17:09:38 +00:00
# specifies the argument to be passed to the sampler constructor, Default: 1
jaeger-sampler-param
2019-02-17 13:41:40 +00:00
2020-04-15 17:09:38 +00:00
# Specifies the custom remote sampler host to be passed to the sampler constructor. Must be a valid URL.
# Default: http://127.0.0.1
jaeger-sampler-host
2019-05-26 08:06:36 +00:00
2020-04-15 17:09:38 +00:00
# Specifies the custom remote sampler port to be passed to the sampler constructor. Must be a number. Default: 5778
jaeger-sampler-port
2019-05-26 08:06:36 +00:00
2020-04-15 17:09:38 +00:00
# Specifies the header name used for passing trace context. Must be a string. Default: uber-trace-id
jaeger-trace-context-header-name
2019-09-22 20:06:22 +00:00
2020-04-15 17:09:38 +00:00
# Specifies the header name used for force sampling. Must be a string. Default: jaeger-debug-id
jaeger-debug-header
2019-09-22 20:06:22 +00:00
2020-04-15 17:09:38 +00:00
# Specifies the header name used to submit baggage if there is no root span. Must be a string. Default: jaeger-baggage
jaeger-baggage-header
2019-09-22 20:06:22 +00:00
2020-04-15 17:09:38 +00:00
# Specifies the header prefix used to propagate baggage. Must be a string. Default: uberctx-
jaeger-tracer-baggage-header-prefix
2019-09-22 20:06:22 +00:00
2020-04-15 17:09:38 +00:00
# specifies the port to use when uploading traces, Default 8126
datadog-collector-port
2019-02-17 13:41:40 +00:00
2020-04-15 17:09:38 +00:00
# specifies the service name to use for any traces created, Default: nginx
datadog-service-name
2019-02-17 13:41:40 +00:00
2020-10-12 21:52:46 +00:00
# specifies the environment this trace belongs to, Default: prod
datadog-environment
2020-04-15 17:09:38 +00:00
# specifies the operation name to use for any traces collected, Default: nginx.handle
datadog-operation-name-override
2020-01-11 21:14:03 +00:00
2020-04-15 17:09:38 +00:00
# Specifies to use client-side sampling for distributed priority sampling and ignore sample rate, Default: true
datadog-priority-sampling
2020-01-11 21:14:03 +00:00
2020-04-15 17:09:38 +00:00
# specifies sample rate for any traces created, Default: 1.0
datadog-sample-rate
2021-01-11 15:59:14 +00:00
</code></pre></div></p> <p>All these options (including host) allow environment variables, such as <code>$HOSTNAME</code> or <code>$HOST_IP</code>. In the case of Jaeger, if you have a Jaeger agent running on each machine in your cluster, you can use something like <code>$HOST_IP</code> (which can be 'mounted' with the <code>status.hostIP</code> fieldpath, as described <a href=https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#capabilities-of-the-downward-api>here</a>) to make sure traces will be sent to the local agent.</p> <h2 id=examples>Examples<a class=headerlink href=#examples title="Permanent link"></a></h2> <p>The following examples show how to deploy and test different distributed tracing systems. These example can be performed using Minikube.</p> <h3 id=zipkin>Zipkin<a class=headerlink href=#zipkin title="Permanent link"></a></h3> <p>In the <a href=https://github.com/rnburn/zipkin-date-server>rnburn/zipkin-date-server</a> GitHub repository is an example of a dockerized date service. To install the example and Zipkin collector run:</p> <div class=highlight><pre><span></span><code>kubectl create -f https://raw.githubusercontent.com/rnburn/zipkin-date-server/master/kubernetes/zipkin.yaml
2020-04-15 17:09:38 +00:00
kubectl create -f https://raw.githubusercontent.com/rnburn/zipkin-date-server/master/kubernetes/deployment.yaml
2021-01-11 15:59:14 +00:00
</code></pre></div> <p>Also we need to configure the NGINX controller ConfigMap with the required values:</p> <div class=highlight><pre><span></span><code>$ echo &#39;
2020-04-15 17:09:38 +00:00
apiVersion: v1
kind: ConfigMap
data:
enable-opentracing: &quot;true&quot;
zipkin-collector-host: zipkin.default.svc.cluster.local
metadata:
2020-05-17 20:30:19 +00:00
name: ingress-nginx-controller
2020-04-15 17:09:38 +00:00
namespace: kube-system
&#39; | kubectl replace -f -
2021-01-11 15:59:14 +00:00
</code></pre></div> <p>In the Zipkin interface we can see the details: <img alt="zipkin screenshot" src=../../../images/zipkin-demo.png title="zipkin collector screenshot"></p> <h3 id=jaeger>Jaeger<a class=headerlink href=#jaeger title="Permanent link"></a></h3> <ol> <li> <p>Enable Ingress addon in Minikube: <div class=highlight><pre><span></span><code>$ minikube addons enable ingress
</code></pre></div></p> </li> <li> <p>Add Minikube IP to /etc/hosts: <div class=highlight><pre><span></span><code>$ echo &quot;$(minikube ip) example.com&quot; | sudo tee -a /etc/hosts
</code></pre></div></p> </li> <li> <p>Apply a basic Service and Ingress Resource: <div class=highlight><pre><span></span><code># Create Echoheaders Deployment
2020-04-15 17:09:38 +00:00
$ kubectl run echoheaders --image=k8s.gcr.io/echoserver:1.4 --replicas=1 --port=8080
# Expose as a Cluster-IP
$ kubectl expose deployment echoheaders --port=80 --target-port=8080 --name=echoheaders-x
# Apply the Ingress Resource
$ echo &#39;
2021-07-29 21:24:20 +00:00
apiVersion: networking.k8s.io/v1beta1
2020-04-15 17:09:38 +00:00
kind: Ingress
metadata:
name: echo-ingress
spec:
rules:
- host: example.com
http:
paths:
- backend:
serviceName: echoheaders-x
servicePort: 80
path: /echo
&#39; | kubectl apply -f -
2021-01-11 15:59:14 +00:00
</code></pre></div></p> </li> <li> <p>Enable OpenTracing and set the jaeger-collector-host: <div class=highlight><pre><span></span><code>$ echo &#39;
2020-04-15 17:09:38 +00:00
apiVersion: v1
kind: ConfigMap
data:
enable-opentracing: &quot;true&quot;
jaeger-collector-host: jaeger-agent.default.svc.cluster.local
metadata:
2020-05-17 20:30:19 +00:00
name: ingress-nginx-controller
2020-04-15 17:09:38 +00:00
namespace: kube-system
&#39; | kubectl replace -f -
2021-01-11 15:59:14 +00:00
</code></pre></div></p> </li> <li> <p>Apply the Jaeger All-In-One Template: <div class=highlight><pre><span></span><code>$ kubectl apply -f https://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/master/all-in-one/jaeger-all-in-one-template.yml
</code></pre></div></p> </li> <li> <p>Make a few requests to the Service: <div class=highlight><pre><span></span><code>$ curl example.com/echo -d &quot;meow&quot;
2018-09-04 23:47:40 +00:00
CLIENT VALUES:
2020-04-15 17:09:38 +00:00
client_address=172.17.0.5
command=POST
real path=/echo
query=nil
request_version=1.1
request_uri=http://example.com:8080/echo
2018-09-04 23:47:40 +00:00
SERVER VALUES:
2020-04-15 17:09:38 +00:00
server_version=nginx: 1.10.0 - lua: 10001
2018-09-04 23:47:40 +00:00
HEADERS RECEIVED:
2020-04-15 17:09:38 +00:00
accept=*/*
connection=close
content-length=4
content-type=application/x-www-form-urlencoded
host=example.com
user-agent=curl/7.54.0
x-forwarded-for=192.168.99.1
x-forwarded-host=example.com
x-forwarded-port=80
x-forwarded-proto=http
x-original-uri=/echo
x-real-ip=192.168.99.1
x-scheme=http
2018-06-24 15:16:34 +00:00
BODY:
meow
2021-01-11 15:59:14 +00:00
</code></pre></div></p> </li> <li> <p>View the Jaeger UI: <div class=highlight><pre><span></span><code>$ minikube service jaeger-query --url
2018-09-04 23:47:40 +00:00
http://192.168.99.100:30183
2021-01-11 15:59:14 +00:00
</code></pre></div></p> <p>In the Jaeger interface we can see the details: <img alt="jaeger screenshot" src=../../../images/jaeger-demo.png title="jaeger collector screenshot"></p> </li> </ol> </article> </div> </div> </main> <footer class=md-footer> <div class=md-footer-nav> <nav class="md-footer-nav__inner md-grid" aria-label=Footer> <a href=../modsecurity/ class="md-footer-nav__link md-footer-nav__link--prev" rel=prev> <div class="md-footer-nav__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg> </div> <div class=md-footer-nav__title> <div class=md-ellipsis> <span class=md-footer-nav__direction> Previous </span> ModSecurity Web Application Firewall </div> </div> </a> <a href=../../../examples/ class="md-footer-nav__link md-footer-nav__link--next" rel=next> <div class=md-footer-nav__title> <div class=md-ellipsis> <span class=md-footer-nav__direction> Next </span> Introduction </div> </div> <div class="md-footer-nav__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"/></svg> </div> </a> </nav> </div> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-footer-copyright> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> </div> </div> </footer> </div> <script src=../../../assets/javascripts/vendor.93c04032.min.js></script> <script src=../../../assets/javascripts/bundle.83e5331e.min.js></script><script id=__lang type=application/json>{"clipboard.copy": "Copy to clipboard", "clipboard.copied": "Copied to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.placeholder": "Type to start searching", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.term.missing": "Missing"}</script> <script>
2020-04-15 17:09:38 +00:00
app = initialize({
base: "../../..",
2021-01-11 15:59:14 +00:00
features: ['navigation.tabs', 'navigation.tabs.sticky', 'navigation.instant', 'navigation.sections'],
2020-04-15 17:09:38 +00:00
search: Object.assign({
2021-01-11 15:59:14 +00:00
worker: "../../../assets/javascripts/worker/search.8c7e0a7e.min.js"
2020-04-15 17:09:38 +00:00
}, typeof search !== "undefined" && search)
})
2021-01-11 15:59:14 +00:00
</script> </body> </html>