Send messages to RabbitMQ from outside kubernetes cluster using nginx-ingress

I am trying to setup a RabbitMQ tasks queue in a kubernetes cluster and need to be able to populate the task queue from outside of the kubernetes cluster. I am trying to accomplish this using the nginx ingress controller. I am running into errors when trying to declare a queue or send messages to an existing queue from outside of the cluster. Using the amqp-tools cli in Ubuntu from outside the cluster I get an error:

$ export BROKER_URL=amqp://<host-name>:80/rabbitmq
$ /usr/bin/amqp-declare-queue --url=$BROKER_URL -q foo -d
logging in to AMQP server: invalid AMQP data

If I do this same thing from a VM inside the cluster, I can create and send message to the queue just fine. I am also able to connect to the RabbitMQ management UI from outside of the cluster but if I try to declare a queue from the UI I get the error Management API returned status code 405 - displayed at the bottom of the screen.

I was reading that the virtual host in RabbitMQ '/' has problems with nginx because of how it parses the host but I am not very experienced with this sort of thing and dont know how to fix that.

Any help with this would be greatly appreciated.

I am deploying the nginx ingress controller with the recommended manifest:

kubectl apply -f 

RabbitMQ is deployed with this manifest:

---
apiVersion: v1
kind: Namespace
metadata: name: rabbitmq labels: app: rabbitmq
---
apiVersion: v1
kind: Service
metadata: name: rabbitmq-service namespace: rabbitmq labels: component: rabbitmq
spec: type: ClusterIP ports: - name: amqp port: 5672 targetPort: 5672 protocol: TCP - name: http port: 80 targetPort: 15672 protocol: TCP selector: app: taskQueue component: rabbitmq
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata: name: rabbit-ingress namespace: rabbitmq annotations: /$1 "false"
spec: rules: - host: <host-name> http: paths: - path: /rabbitmq/?(.*) backend: serviceName: rabbitmq-service servicePort: 5672
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata: name: rabbit-manage-ingress namespace: rabbitmq annotations: /$1 "false"
spec: rules: - host: <host-name> http: paths: - path: /rabbitmq-manage/?(.*) backend: serviceName: rabbitmq-service servicePort: 80
---
apiVersion: v1
kind: ReplicationController
metadata: labels: app: taskQueue component: rabbitmq name: rabbitmq-controller namespace: rabbitmq
spec: replicas: 1 template: metadata: labels: app: taskQueue component: rabbitmq spec: containers: - image: rabbitmq:3-management name: rabbitmq ports: - containerPort: 5672 - containerPort: 15672 resources: limits: cpu: 100m
2

1 Answer

As far as i know, RabbitMQ does not provide a HTTP-API for interacting (at least it's not the default). NGINX-Ingress cannot use an Ingress resource to expose anything different to a HTTP-Service. Take a look at the documentation to learn how to expose a TCP- or UDP-Based service.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like