无法访问RabbitMQ用户界面

huangapple go评论87阅读模式
英文:

Unable to access RabbitMQ UI

问题

我使用以下清单在Kubernetes中部署了RabbitMQ。

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: rabbitmq
  namespace: X 
spec:
  serviceName: rabbitmq
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: rabbitmq:v01
        ports:
          - containerPort: 15672
            name: rabbitmq
          - containerPort: 5672
        env:
          - name: RABBITMQ_DEFAULT_USER
            value: "..."
          - name: RABBITMQ_DEFAULT_PASS
            value: "..."
        livenessProbe:
          tcpSocket:
            port: 5672
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          tcpSocket:
            port: 5672
          initialDelaySeconds: 10
          periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
spec:
  ports:
  - port: 5672
    protocol: TCP
    targetPort: 5672
  selector:
    app: rabbitmq
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: rmq
  namespace: X
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`Y`) 
    kind: Rule
    services:
    - name: rabbitmq
      port: 5672
  tls: {}

在应用此清单后,我可以看到我的Pod正在运行。但是当我尝试进行端口转发时,我无法访问RabbitMQ UI。我遇到了“内部服务器错误”或“错误的网关”错误。

在Pod的日志中,我可以看到:

Server startup complete; 3 plugins started.
* rabbitmq_prometheus
* rabbitmq_web_dispatch
* rabbitmq_management_agent

In the logs I can see:

2023-06-05 21:23:36.319429+00:00 [info] <0.1006.0> accepting AMQP connection <0.1006.0> (IP1:34330 -> IP2:5672)
2023-06-05 21:23:36.319611+00:00 [error] <0.1006.0> closing AMQP connection <0.1006.0> (IP1:34330 -> IP2:5672):
2023-06-05 21:23:36.319611+00:00 [error] <0.1006.0> {bad_header,<<"GET / HT">>}

我做错了什么?

英文:

I deployed RabbitMQ in Kubernetes with the manifest below.

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: rabbitmq
  namespace: X 
spec:
  serviceName: rabbitmq
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: rabbitmq:v01
        ports:
          - containerPort: 15672
            name: rabbitmq
          - containerPort: 5672
        env:
          - name: RABBITMQ_DEFAULT_USER
            value: "..."
          - name: RABBITMQ_DEFAULT_PASS
            value: "..."
        livenessProbe:
          tcpSocket:
            port: 5672
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          tcpSocket:
            port: 5672
          initialDelaySeconds: 10
          periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
spec:
  ports:
  - port: 5672
    protocol: TCP
    targetPort: 5672
  selector:
    app: rabbitmq
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: rmq
  namespace: X
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`Y`) 
    kind: Rule
    services:
    - name: rabbitmq
      port: 5672
  tls: {}

After applying this manifest I can see that my pod is running. But when I try to port forward I don't have access to RabbitMQ UI. I have the error 'internal server error' or 'bad gateway'.

In the logs of the pod I can see :

Server startup complete; 3 plugins started.
* rabbitmq_prometheus
* rabbitmq_web_dispatch
* rabbitmq_management_agent

In the logs I can see:

2023-06-05 21:23:36.319429+00:00 [info] <0.1006.0> accepting AMQP connection <0.1006.0> (IP1:34330 -> IP2:5672)
2023-06-05 21:23:36.319611+00:00 [error] <0.1006.0> closing AMQP connection <0.1006.0> (IP1:34330 -> IP2:5672):
2023-06-05 21:23:36.319611+00:00 [error] <0.1006.0> {bad_header,<<"GET / HT">>}

Where am I wrong ?

答案1

得分: 1

有两个问题与您的清单相关:

  1. 您的 Service 应该指向 RabbitMQ 的端口 15672,以便访问用户界面,如此在此 文档 中所述,而不是 5672

  2. ServiceStatefulSet 都应该在相同的命名空间中。在您的情况下,它们分别位于 defaultx 命名空间中。

英文:

There are 2 issues with your manifests:

  1. Your Service should be pointing to RabbitMQ's port 15672 for accessing UI as mentioned in this document instead of 5672.

  2. Both Service and StatefulSet should be in same namespace. In your case they are in default and x respectively.

huangapple
  • 本文由 发表于 2023年6月6日 04:56:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409946.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定