使用nginxingress从kubernetes集群外部向RabbitMQ发送消息



我正试图在kubernetes集群中设置RabbitMQ任务队列,并且需要能够从kubernete集群外部填充任务队列。我正在尝试使用nginxingress控制器来实现这一点。尝试声明队列或从集群外部向现有队列发送消息时遇到错误。在集群外的Ubuntu中使用amqp工具cli,我得到一个错误:

$ 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

如果我在集群内的VM上做同样的事情,我可以创建消息并将其发送到队列。我还可以从集群外部连接到RabbitMQ管理UI,但如果我尝试从UI声明队列,我会在屏幕底部显示错误Management API returned status code 405 -

我读到RabbitMQ"/"中的虚拟主机因nginx解析主机的方式而出现问题,但我对这类事情没有太多经验,也不知道如何解决。

如有任何帮助,我们将不胜感激。

我正在使用推荐的清单部署nginx入口控制器:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml

RabbitMQ使用以下清单进行部署:

---
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:
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/ssl-redirect: "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:
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/ssl-redirect: "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

据我所知,RabbitMQ没有提供用于交互的HTTP-API(至少它不是默认的(。NGINX Ingress不能使用Ingress资源向HTTP服务公开任何不同的内容。查看文档,了解如何公开基于TCP或UDP的服务。

相关内容

  • 没有找到相关文章

最新更新