Connecting RabbitMQ | Pika | Kubernetes

7/18/2018

I have a kubernetes cluster running. Inside this I have python application running as a pod.

This app is talking to rabbitmq which is also one of the pods of the same cluster. So the whole connection is done using internal IPs.

The problem is I have a service for rabbitmq, so I am providing the service IP for connection. It looks something like this ( with pika )

credentials = pika.PlainCredentials(rabbituser, rabbitpass)
connection = pika.BlockingConnection(pika.ConnectionParameters(host=QHost, port=80, credentials=credentials))
channel = connection.channel()

As you can see the connection I am trying to make is to port 80 which is open in the k8s service.

Now it should redirect it to respective pod which is rabbitmq, but it is trying to connect to port 5672

That means, error is because it is trying to connect to service-ip:5672, which is not there.

I want it to forward the request to the rabbit mq pod where the service is pointed.

I hope that I have explained main things.

Please ask if more details required. Thanks

-- Saurabh
devops
kubernetes
pika
rabbitmq

0 Answers