介绍
Jaeger 是一个开源的端到端的分布式跟踪系统, 允许用户在复杂的分布式系统中监控和排查故障。
官方文档地址:https://www.jaegertracing.io/docs/1.47/getting-started/
部署
这里使用istio的快速部署
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/addons/jaeger.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: jaeger
namespace: istio-system
labels:
app: jaeger
spec:
selector:
matchLabels:
app: jaeger
template:
metadata:
labels:
app: jaeger
sidecar.istio.io/inject: "false"
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "14269"
spec:
containers:
- name: jaeger
image: "docker.io/jaegertracing/all-in-one:1.35"
env:
- name: BADGER_EPHEMERAL
value: "false"
- name: SPAN_STORAGE_TYPE
value: "badger"
- name: BADGER_DIRECTORY_VALUE
value: "/badger/data"
- name: BADGER_DIRECTORY_KEY
value: "/badger/key"
- name: COLLECTOR_ZIPKIN_HOST_PORT
value: ":9411"
- name: MEMORY_MAX_TRACES
value: "50000"
- name: QUERY_BASE_PATH
value: /jaeger
livenessProbe:
httpGet:
path: /
port: 14269
readinessProbe:
httpGet:
path: /
port: 14269
volumeMounts:
- name: data
mountPath: /badger
resources:
requests:
cpu: 10m
volumes:
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: tracing
namespace: istio-system
labels:
app: jaeger
spec:
type: ClusterIP
ports:
- name: http-query
port: 80
protocol: TCP
targetPort: 16686
# Note: Change port name if you add '--query.grpc.tls.enabled=true'
- name: grpc-query
port: 16685
protocol: TCP
targetPort: 16685
selector:
app: jaeger
---
# Jaeger implements the Zipkin API. To support swapping out the tracing backend, we use a Service named Zipkin.
apiVersion: v1
kind: Service
metadata:
labels:
name: zipkin
name: zipkin
namespace: istio-system
spec:
ports:
- port: 9411
targetPort: 9411
name: http-query
selector:
app: jaeger
---
apiVersion: v1
kind: Service
metadata:
name: jaeger-collector
namespace: istio-system
labels:
app: jaeger
spec:
type: ClusterIP
ports:
- name: jaeger-collector-http
port: 14268
targetPort: 14268
protocol: TCP
- name: jaeger-collector-grpc
port: 14250
targetPort: 14250
protocol: TCP
- port: 9411
targetPort: 9411
name: http-zipkin
selector:
app: jaeger
Jaeger 与 Istio 一起使用时无需特殊的配置。安装 Jaeger 完毕后,需要指定 Istio 代理向 Deployment 发送流量。 在安装时,可以使用 --set values.global.tracer.zipkin.address=<jaeger-collector-address>:9411
进行配置。参考更多 ProxyConfig.Tracing 高级配置,如 TLS 设置。
访问UI
修改tracing svc为NodePort。
使用bookinfo服务测试tracing。如果没有修改采样率的话需要访问100次。
PS:如果之前使用了skywalking作为默认的providers,需要卸载istio重新安装。再修改ingress-gateway为NodePort。
for i in `seq 1 100`; do curl -s -o /dev/null http://$GATEWAY_URL/productpage; done
从仪表盘左边面板的 Service 下拉列表中选择 productpage 并点击 Find Traces:
点击位于最上面的最近一次追踪,查看对应最近一次访问 /productpage 的详细信息:
追踪信息由一组 Span 组成,每个 Span 对应一个 Bookinfo Service。这些 Service 在执行 /productpage 请求时被调用,或是 Istio 内部组件,例如:istio-ingressgateway。