因此,我试图使用jaeger跟踪我的spring boot应用程序的日志,那么如果将我的应用程序和jaeger部署在kubernetes上,应该执行哪些步骤。
我已经成功部署了Jaeger和Spring Boot应用程序
现在如何在服务中配置jaeger。
我的服务在jaegar控制台中不可见。

spring-boot - 当两个都部署在kubernetes上时,Spring Boot应用程序中的jaeger配置-LMLPHP

我已将以下配置添加到yml:

opentracing.jaeger.udp-sender.host=localhost
opentracing.jaeger.udp-sender.port=6831

apiVersion: v1
kind: List
items:
- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: jaeger
    labels:
      app: jaeger
      app.kubernetes.io/name: jaeger
      app.kubernetes.io/component: all-in-one
  spec:
    replicas: 1
    strategy:
      type: Recreate
    template:
      metadata:
        labels:
          app: jaeger
          app.kubernetes.io/name: jaeger
          app.kubernetes.io/component: all-in-one
        annotations:
          prometheus.io/scrape: "true"
          prometheus.io/port: "16686"
      spec:
          containers:
          -   env:
              - name: COLLECTOR_ZIPKIN_HTTP_PORT
                value: "9411"
              image: jaegertracing/all-in-one
              name: jaeger
              ports:
                - containerPort: 5775
                  protocol: UDP
                - containerPort: 6831
                  protocol: UDP
                - containerPort: 6832
                  protocol: UDP
                - containerPort: 5778
                  protocol: TCP
                - containerPort: 16686
                  protocol: TCP
                - containerPort: 9411
                  protocol: TCP
              readinessProbe:
                httpGet:
                  path: "/"
                  port: 14269
                initialDelaySeconds: 5
- apiVersion: v1
  kind: Service
  metadata:
    name: jaeger-query
    labels:
      app: jaeger
      app.kubernetes.io/name: jaeger
      app.kubernetes.io/component: query
  spec:
    ports:
      - name: query-http
        port: 80
        protocol: TCP
        targetPort: 16686
    selector:
      app.kubernetes.io/name: jaeger
      app.kubernetes.io/component: all-in-one
    type: LoadBalancer
- apiVersion: v1
  kind: Service
  metadata:
    name: jaeger-collector
    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: all-in-one
    type: ClusterIP
- apiVersion: v1
  kind: Service
  metadata:
    name: jaeger-agent
    labels:
      app: jaeger
      app.kubernetes.io/name: jaeger
      app.kubernetes.io/component: agent
  spec:
    ports:
    - name: agent-zipkin-thrift
      port: 5775
      protocol: UDP
      targetPort: 5775
    - name: agent-compact
      port: 6831
      protocol: UDP
      targetPort: 6831
    - name: agent-binary
      port: 6832
      protocol: UDP
      targetPort: 6832
    - name: agent-configs
      port: 5778
      protocol: TCP
      targetPort: 5778
    clusterIP: None
    selector:
      app.kubernetes.io/name: jaeger
      app.kubernetes.io/component: all-in-one
- apiVersion: v1
  kind: Service
  metadata:
    name: zipkin
    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
    clusterIP: None
    selector:
      app.kubernetes.io/name: jaeger
      app.kubernetes.io/component: all-in-one


输出og kubectl获取服务jaeger查询
Name:                     jaeger-query
Namespace:                default
Labels:                   app=jaeger
                          app.kubernetes.io/component=query
                          app.kubernetes.io/name=jaeger
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                            {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"jaeger",
                            "app.kubernetes.io/component":"query","app.kuber...
Selector:                 app.kubernetes.io/component=all-in-one,app.kubernetes.io/name=jaeger
Type:                     LoadBalancer
IP:                       10.24.14.223
LoadBalancer Ingress:     35.222.40.241
Port:                     query-http  80/TCP
TargetPort:               16686/TCP
NodePort:                 query-http  30290/TCP
Endpoints:                10.20.2.7:16686
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

最佳答案

您将opentracing-spring-jaeger-starter library添加到项目中,该项目仅包含提供OpenTracing的io.opentracing.Tracer接口(interface)的Jaeger实现所需的代码。

由于您已经在kubernetes中部署了jaeger并通过负载均衡器服务将其公开,因此您可以使用负载均衡器的IP和端口从Kubernetes集群外部与其连接。

关于spring-boot - 当两个都部署在kubernetes上时,Spring Boot应用程序中的jaeger配置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61149872/

10-10 18:24