如何将我的Kubernetes pod连接到远程Jaeger



我正试图将我的pod从Kubernetes(k8s(集群连接到远程Jaeger服务器。我已经测试过了,如果它们都在同一台机器上,它可以很好地工作。然而,当我在k8s上运行我的应用程序时,尽管我使用的是物理IP,但我的应用无法连接到Jaeger。首先,我尝试过这个:

containers:
- name: api
env:
- name: OTEL__AGENT_HOST
value: <my-physical-ip>
- name: OTEL__AGENT_PORT
value: "6831"

在阅读了互联网上的文档后,我将Jaeger代理添加到我的部署中,作为一个sidecar容器,如下所示。

containers:
- name: api
env:
- name: OTEL__AGENT_HOST
value: "localhost"
- name: OTEL__AGENT_PORT
value: "6831"
- image: jaegertracing/jaeger-agent
name: jaeger-agent
ports:
- containerPort: 5775
protocol: UDP
- containerPort: 6831
protocol: UDP
- containerPort: 6832
protocol: UDP
- containerPort: 5778
protocol: TCP
args: ["--reporter.grpc.host-port=<my-physical-ip>:14250"]

它似乎在两个容器上都能很好地工作。但在Jaeger的收集器上,我收到了这样的日志:

{"level":"warn","ts":1641987200.2678068,"caller":"channelz/logging.go:62","msg":"[core]grpc: Server.Serve failed to create ServerTransport: connection error: desc = "transport: http2Server.
HandleStreams failed to receive the preface from client: read tcp 172.20.0.4:14250-><the-ip-of-machine-my-pods-are-deployed>:32852: i/o timeout"","system":"grpc","grpc_log":true}

我在远程机器上的Jaeger收集器上暴露了端口14267,然后将args: ["--reporter.grpc.host-port=<my-physical-ip>:14250"]更改为args: ["--reporter.grpc.host-port=<my-physical-ip>:14267"],它就工作了。

您尝试过使用jaeger运算符吗?https://github.com/jaegertracing/jaeger-operator

以下是安装方式:

kubectl create namespace observability 
kubectl create -f https://github.com/jaegertracing/jaeger-operator/releases/download/v1.31.0/jaeger-operator.yaml -n observability

然后您可以创建Jaeger实例,该实例将启动收集器、代理、查询等Jaeger组件。您也可以定义存储。。如的弹性搜索

apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
name: simple-prod-es
spec:
strategy: production
storage:
type: elasticsearch 
options:
es:
server-urls: https://search-test-g7fbo7pzghdquvvgxty2pc6lqu.us-east-2.es.amazonaws.com
index-prefix: jaeger-span
username: test
password: xxxeee

然后,在应用程序的部署yaml文件中,您需要将代理配置为sidecar(或者您可以将代理用作deamonset(,以便将请求转发到收集器。。

更多详细信息请点击此处:https://www.jaegertracing.io/docs/1.31/operator/#deployment-策略

最新更新