我正在尝试与其他Pod通信服务,但无法访问它。
我正在使用GKE,尝试了不同的端口和设置,并查看了代码:https://github.com/spreaker/prometheus-pgbouncer-exporter
我的部署文件具有:
spec:
containers:
- name: exporter
image: ...
ports:
- containerPort: 9127
env:
...
服务:
type: NodePort
ports:
- port: 9127
protocol: "TCP"
name: exporter
当我尝试描述svc时:
Name: ...-pg-bouncer-exporter-service
Namespace: backend
Labels: app=...-pg-bouncer-exporter
Annotations: <none>
Selector: app=...-pg-bouncer-exporter
Type: NodePort
IP: 10.0.19.80
Port: exporter 9127/TCP
TargetPort: 9127/TCP
NodePort: exporter 31296/TCP
Endpoints: 10.36.7.40:9127
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
还有豆荚本身:
Containers:
exporter:
Container ID: docker://...
Image: ...
Image ID: docker-pullable:...
Port: 9127/TCP
Host Port: 0/TCP
State: Running
Started: Wed, 10 Jul 2019 11:17:38 +0200
Ready: True
Restart Count: 0
如果我访问该容器,则表示我从curl中正确接收了数据:
/ # curl localhost:9127/metrics
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes ....
还可以对其服务进行端口转发:
$ kubectl port-forward services/...-pg-bouncer-exporter-service 9127:9127 -n backend
Forwarding from 127.0.0.1:9127 -> 9127
Forwarding from [::1]:9127 -> 9127
Handling connection for 9127
现在我从同一网络中的其他Pod收到此错误:
curl 10.36.7.40:9127/metrics
curl: (7) Failed to connect to 10.36.7.40 port 9127: Connection refused
如果我为9127创建一个LivenessProbe TCP,我将收到此错误:
Liveness probe failed: dial tcp 10.36.7.40:9127: connect: connection refused
我看不到我做错了什么,我为其他服务使用了相同的设置。
谢谢!
答案 0 :(得分:2)
所以问题是:
我要使用127.0.0.1
代替PGBOUNCER_EXPORTER_HOST使用0.0.0.0
。
那解决了这个问题。