简体   繁体   English

服务无法与k8s集群中的rabbitmq通信

[英]service cannot communicate with rabbitmq in k8s cluster

I have k8s cluster (1.16) with one service in it's specific namespace, and a stateful set of rabbitmq (image: 3.8.0-alpine) with 3 replicas, one on each of my workers, in a different namespace.我有 k8s 集群(1.16),在它的特定命名空间中有一个服务,还有一组有状态的 rabbitmq(图像:3.8.0-alpine)有 3 个副本,一个在我的每个工作人员上,在不同的命名空间中。 I configured the service to connect rabbitmq with amqp://user:password@rabbitmq-service.rabbitmq-namespace:5672我将服务配置为使用amqp://user:password@rabbitmq-service.rabbitmq-namespace:5672连接rabbitmq

I'm getting this error in the logs of my service:我在我的服务日志中收到此错误:

Rabbit mq disconnected connect EHOSTUNREACH <rabbitmq_svc_ip>:5672

rabbitmq seems to be working fine. rabbitmq 似乎工作正常。 there are no errors shown in the pods. Pod 中没有显示错误。

What can I check to find the issue and make them communicate?我可以检查什么来找到问题并让他们沟通?

You asked for how to approach this issue, and so I am including how I would approach it.你问了如何处理这个问题,所以我包括了我将如何处理它。

I would describe your service to see if your pod ips are listed as endpoints behind it.我会描述你的服务,看看你的 pod ip 是否被列为它背后的端点。

kubectl describe service <rabbitmq-service>

If they are not listed, then I would look at your service's selector to make sure that it matches your statefulset.如果它们未列出,那么我会查看您的服务的选择器以确保它与您的 statefulset 匹配。 If they are listed, then I would double check that your Service Port is actually 5672, and then I would exec into your pod where your app is running and try to ping the service name in your connection string to make sure it's reachable from your app's namespace.如果它们被列出,那么我会仔细检查你的服务端口实际上是 5672,然后我会执行到你的应用程序运行的 pod 并尝试ping你的连接字符串中的服务名称以确保它可以从你的应用程序的命名空间。 I would also try to do telnet tests to your service name and port to ensure that your app can connect to your service on that port, and I would telnet to your rabbitmq pod ips and ports to ensure that your app can connect to them.我还会尝试对您的服务名称和端口进行telnet测试,以确保您的应用程序可以连接到该端口上的服务,并且我会 telnet 到您的 rabbitmq pod ips 和端口,以确保您的应用程序可以连接到它们。 If telnet isn't in your image, I would install it for troubleshooting purposes.如果 telnet 不在您的映像中,我会安装它以进行故障排除。

kubectl exec -it <app-pod> -n <namespace> /bin/bash
telnet <pod ip or service name> <port> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM