Linkerd 2.10 series
- Linkerd v2.10 Service Mesh
- Tencent Cloud K8S deployment Service Mesh — Linkerd2 & Traefik2 deployment emojivoto application
- Learn about the basic features of Linkerd 2.10 and step into the era of Service Mesh
- Linkerd 2.10 – Add your service to Linkerd
- Linkerd 2.10 — Automated Canary release
- Linkerd 2.10 — Automatic rotation controls plane TLS and Webhook TLS credentials
- Linkerd 2.10 — How do I configure external Prometheus instances
- Linkerd 2.10 – Configure proxy concurrency
- Linkerd 2.10 – Configure retry
- Linkerd 2.10 — Configure timeout
- Linkerd 2.10 – Controls the plane debug endpoint
- Linkerd 2.10 – Use Kustomize to customize Linkerd configuration
Linkerd 2.10 中文 版
- linkerd.hacker-linner.com
Using distributed tracing in practice can be complex, and in order to explain at a high level what you get and how it is done, we put together a list of myths.
This guide will walk you through configuring emojivoto and enabling tracing. Skip to the end for some suggestions on the best way to use distributed tracing with Linkerd.
To use distributed tracing, you need:
- Install the Linkerd-Jaeger extension.
- Modify your application to emit spans.
In the case of Emojivoto, once all these steps have been completed, there is a topology that looks like this:
A prerequisite for
- To use this guide, you need to have Linkerd installed on your cluster. If you have not already done so, follow the Linkerd Installation guide.
Install the Linkerd-Jaeger extension
The first step in obtaining distributed tracing Settings is to install the Linkerd-Jaeger extension on your cluster. This extension consists of a collector, a Jaeger back end, and a Jaeger-Injector. The collector consumes the spans emitted from the grid and your application and sends them to the Jaeger back end, which stores them and provides a dashboard to view them. Jaeger-injector is responsible for configuring the Linkerd agent to issue spans.
To install the Linkerd-Jaeger extension, run the following command:
linkerd jaeger install | kubectl apply -f -
Copy the code
You can verify that the Linkerd-Jaeger extension is properly installed by running the following command:
linkerd jaeger check
Copy the code
Install Emojivoto
Add emojivoto to your cluster and inject it using the Linkerd proxy:
linkerd inject https://run.linkerd.io/emojivoto.yml | kubectl apply -f -
Copy the code
Before proceeding to the next step, make sure everything is up and run the following command using Kubectl:
kubectl -n emojivoto rollout status deploy/web
Copy the code
Modify the application
Unlike most of the capabilities of the service grid, distributed tracing requires modifying the source of the application. Tracing requires some way to bind incoming requests with your application and outgoing requests to related services. To do this, you add headers to each request that contain the unique ID of the trace. Linkerd uses b3 Propagation to connect these things together.
We have modified emojivoto to use this information to detect its request, and the COMMIT shows how this is done. For most programming languages, it simply needs to add a client library to handle this problem. Emojivoto uses the OpenCensus client, but other clients are also available.
To enable tracing in Emojivoto, run:
kubectl -n emojivoto set env --all deploy OC_AGENT_HOST=collector.linkerd-jaeger:55678
Copy the code
This command adds an environment variable that enables the application to propagate the context and issue the span.
To explore the Jaeger
With vote-bot starting to track each request, the span should now appear in Jaeger. To access the UI, run:
linkerd jaeger dashboard
Copy the code
You can search for any service in the dropdown list, and then click Find Traces. Vote-bot is a good way to get started.
Clicking on a specific trace will provide all the details and you will be able to see the span of each agent!
There must be a lot of Linkerd-proxy span in this output. Internally, the proxy has a server side and a client side. When the request passes through the proxy, it is received by the server and then issued by the client. For a single request passed between two mesh pods, there are a total of four spans. Two will be on the source side when the request traverses the agent, and two will be on the target side when the remote agent receives the request.
In addition, because the agent has added application metadata as tracing properties, users can jump directly from the Linkerd-Web dashboard to the relevant resource tracking by clicking the Jaeger icon in the degree scale, as shown below
Clean up the
To clean up, uninstall the Linkerd-Jaeger extension and Emojivoto by running the following command:
linkerd jaeger uninstall | kubectl delete -f -
kubectl delete ns emojivoto
Copy the code
Bring your own Jaeger
If you have an existing Jaeger installation, you can configure the OpenCensus collector to send traces to it instead of the Jaeger instance built into the Linkerd-Jaeger extension.
linkerd jaeger install --set collector.jaegerAddr='http://my-jaeger-collector.my-jaeger-ns:14268/api/traces' | kubectl apply -f -
Copy the code
You can also manually edit the OpenCensus configuration to export it to any backend it supports. See the OpenCensus documentation for a complete list.
troubleshooting
I don’t see any span of agency
The Linkerd agent uses b3 Propagation format. Some client libraries, such as Jaeger, use a different format by default. You need to configure the client library to use b3 format for the broker to participate in tracing.
advice
Ingress
Ingress is a particularly important component of distributed tracing because it creates the root span of each trace and is responsible for deciding whether or not that trace should be sampled. Letting ingress make all sampling decisions ensures that the entire trace is sampled or not sampled, and avoids creating partial traces.
Distributed tracing systems all rely on services to propagate metadata about the current trace from the request received to the request sent. This unary data is called the trace context and is typically encoded in one or more request headers. There are many different tracecontext header formats, and while we hope that the ecosystem will eventually converge to an open standard like the W3C tracecontext tracecontext, we’ll just use b3 format today. As one of the first widely used formats, it has the widest support, especially in portals such as Nginx.
This reference architecture includes a simple Nginx configuration that samples 50% of the trace and sends the trace data to the collector (using the Zipkin protocol). Any entry controller can be used here instead of Nginx, as long as it:
- Support for probabilistic sampling
- Encodes trace context in B3 format
- Issue spans in protocols supported by the OpenCensus collector
If using helm to install ingress-nginx, you can configure tracing using the following command:
controller:
config:
enable-opentracing: "true"
zipkin-collector-host: linkerd-collector.linkerd
Copy the code
The client library
While a service can propagate trace propagation headers manually, it is often much easier to use libraries that do three things:
- The trace context is propagated from the incoming to outgoing request headers
- Modify the trace context (that is, start a new span)
- Transfer this data to the trace collector
We recommend using OpenCensus in your service and configuring it:
- B3 Propagation (this is the default)
- the OpenCensus agent exporter
OpenCensus Agent exporter exports trace data to the OpenCensus collector through the gRPC API. Details on how to configure OpenCensus vary from language to language, but there are many guides for popular languages. You can also see end-to-end examples in Go using our sample application, Emojivoto.
You may notice that the OpenCensus project is in maintenance mode and will be part of OpenTelemetry. Unfortunately, OpenTelemetry is not yet ready for production, so OpenCensus remains our current recommendation.
Many other trace client libraries are also available. Just make sure you are using the B3 propagation format and that the client library can export its span in the format that the collector has been configured to receive.
Collector: OpenCensus
The OpenCensus Collector receives trace data from the OpenCensus Agent and may convert and filter this data before sending it to the Jaeger. Sending OpenCensus to OpenCensus Collector gives us a great deal of flexibility: we can switch to any backend that OpenCensus supports without interrupting the application.
The backend: Jaeger
Jaeger is one of the most widely used trace backends, and for good reason: it’s easy to use and does a good job of visual tracing. However, you can switch to any backend supported by OpenCensus.
Linkerd
If your application has Linkerd injected, the Linkerd agent participates in tracing and sends trace data to the OpenCensus collector. This enriches the trace data and allows you to see exactly how much time the request is spending on the agent and the line.
Although Linkerd can only actively participate in the use of TRACE propagating in B3 format, Linkerd will always transparently forward unknown headers, meaning that it will never interfere with trace propagating in other formats.
I am weishao wechat: uuhells123 public number: hackers afternoon tea add my wechat (mutual learning exchange), pay attention to the public number (for more learning materials ~)Copy the code