gpt4 book ai didi

spring-boot - 当它们都部署在 kubernetes 上时,spring boot 应用程序中的 jaeger 配置

转载 作者:行者123 更新时间:2023-12-02 11:33:01 24 4
gpt4 key购买 nike

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

showing all the services running on my kubernetes cluster

我在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 get service jaeger-query

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>

最佳答案

所以对我有用的解决方案是 -我在应用程序的 application.properties 文件中进行了以下更改

opentracing.jaeger.udp-sender.host=http://<load_balancer_ip_of_jaeger_service>:<expose_port>(example ":80")
opentracing.jaeger.http-sender.url=http://<cluster_ip_or_load_balancer_ip_of jaeger_collector>:<expose_port>/api/traces(example of expose port ":1468")

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com