Jaeger 是Uber推出的一款开源分布式追踪系统,兼容OpenTracing API。分布式追踪系统用于记录请求范围内的信息,包括一次调用的服务链路以及每个服务的延时,能够帮助我们很好的分析微服务间链路调用的错误及瓶颈。
OpenTracing api 及其原理将在下一篇 blog 中介绍。由于 istio 默认支持 Jaeger,因此准备测试下 Jaeger与Istio的集成。
Jaeger 整体架构如下图,主要包括3个组件: agent,collector以及query(UI)
agent: 用于监听应用传来的链路信息,并传递给collector,
collector:收集链路信息,并持久化。 其支持的后端存储为 Cassandra、ElasticSearch。此外也支持对接 Kafka,以进行后续的流式处理(可连入 spark、flink 以进一步分析)
query:提供查询的 api 接口及 UI 界面
在 istio 中,我们可以不部署 agent 组件。因为在 istio 中,若在 mixer 组件配置 zipkin-address-url 参数,则会默认为服务网格中的服务创建调用链路信息,并发送到配置的地址中。
这里的zipkin-address-url 并非真正部署的 zipkin, 而是这个地址可以兼容 zipkin 所使用的数据格式。
1.all-in-one
由于 all-in-one 模式是用于测试的demo,因此所有的链路信息默认存储在内存中,无法用于生产环境。
若单独在 K8s 平台中, Jaeger 官方推荐使用 Jaeger Operator 部署。Operator 部署相对来说比较简单,参考连接https://www.jaegertracing.io/docs/1.14/operator/,此处不再赘述。
Operator 是 K8s 平台提供的一种可自定义 Controller 的方式,此外仍需定义一系列的 CRD,自定义 Operator通过监听 CRD 的状态更新,实现一系列的逻辑,比如创建 deployment 等。
2.生产环境部署
zipkin: address: zipkin.istio-system:9411
#jaeger-cm.yaml apiVersion: v1 kind: ConfigMap metadata: name: jaeger-configuration namespace: istio-system labels: app: jaeger app.kubernetes.io/name: jaeger data: span-storage-type: elasticsearch collector: | es: server-urls: http://es-ip:9200 collector: zipkin: http-port: 9411 query: | es: server-urls: http://es-ip:9200 agent: | collector: host-port: "jaeger-collector:14267"
#ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: ingress.kubernetes.io/protocol: http name: istio-jaeger namespace: istio-system spec: rules: - host: domain http: paths: - backend: service: name: jaeger-query port: name: jaeger-query path: / pathType: ImplementationSpecific
--- apiVersion: apps/v1 kind: Deployment metadata: name: jaeger-collector namespace: istio-system labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: collector spec: replicas: 1 selector: matchLabels: app.kubernetes.io/name: jaeger app.kubernetes.io/component: collector strategy: type: Recreate template: metadata: labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: collector annotations: prometheus.io/scrape: "true" prometheus.io/port: "14268" spec: containers: - image: jaegertracing/jaeger-collector:1.23.0 name: jaeger-collector args: ["--config-file=/conf/collector.yaml"] ports: - containerPort: 14267 protocol: TCP - containerPort: 14268 protocol: TCP - containerPort: 9411 protocol: TCP readinessProbe: httpGet: path: "/" port: 14269 volumeMounts: - name: jaeger-configuration-volume mountPath: /conf env: - name: SPAN_STORAGE_TYPE valueFrom: configMapKeyRef: name: jaeger-configuration key: span-storage-type volumes: - configMap: name: jaeger-configuration items: - key: collector path: collector.yaml name: jaeger-configuration-volume --- apiVersion: v1 kind: Service metadata: name: jaeger-collector namespace: istio-system labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: collector spec: ports: - name: jaeger-collector-tchannel port: 14267 protocol: TCP targetPort: 14267 - name: jaeger-collector-http port: 14268 protocol: TCP targetPort: 14268 - name: jaeger-collector-zipkin port: 9411 protocol: TCP targetPort: 9411 selector: app.kubernetes.io/name: jaeger app.kubernetes.io/component: collector type: ClusterIP --- apiVersion: v1 kind: Service metadata: name: zipkin namespace: istio-system labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: zipkin spec: ports: - name: jaeger-collector-zipkin port: 9411 protocol: TCP targetPort: 9411 selector: app.kubernetes.io/name: jaeger app.kubernetes.io/component: collector type: ClusterIP --- apiVersion: apps/v1 kind: Deployment metadata: name: jaeger-query namespace: istio-system labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: query spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app.kubernetes.io/name: jaeger app.kubernetes.io/component: query template: metadata: labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: query annotations: prometheus.io/scrape: "true" prometheus.io/port: "16686" spec: containers: - image: jaegertracing/jaeger-query:1.23.0 name: jaeger-query args: ["--config-file=/conf/query.yaml"] ports: - containerPort: 16686 protocol: TCP readinessProbe: httpGet: path: "/" port: 16687 volumeMounts: - name: jaeger-configuration-volume mountPath: /conf env: - name: SPAN_STORAGE_TYPE valueFrom: configMapKeyRef: name: jaeger-configuration key: span-storage-type volumes: - configMap: name: jaeger-configuration items: - key: query path: query.yaml name: jaeger-configuration-volume --- apiVersion: v1 kind: Service metadata: name: jaeger-query namespace: istio-system labels: app: jaeger app.kubernetes.io/name: jaeger app.kubernetes.io/component: query spec: ports: - name: jaeger-query port: 80 protocol: TCP targetPort: 16686 selector: app.kubernetes.io/name: jaeger app.kubernetes.io/component: query ---
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)