service cannot communicate with rabbitmq in k8s cluster

你说的曾经没有我的故事 提交于 2021-01-29 14:24:02

问题


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. I configured the service to connect rabbitmq with amqp://user:password@rabbitmq-service.rabbitmq-namespace:5672

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. there are no errors shown in the pods.

What can I check to find the issue and make them communicate?


回答1:


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.

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. 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. 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. If telnet isn't in your image, I would install it for troubleshooting purposes.

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


来源:https://stackoverflow.com/questions/63942591/service-cannot-communicate-with-rabbitmq-in-k8s-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!