通过 kubernetes ingress 公开 rabbitmq 管理

Expose rabbitmq managment via kubernetes ingrress

我有一个部署了 rabbitmq 的 kubernetes 集群。我想以我可以在浏览器中访问它的方式公开 rabbitmanagment UI。为此,我有一个部署、服务和入口文件:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
        - image: rabbitmq:3.8.9-management
          name: rabbitmq
          ports:
            - containerPort: 5672
            - containerPort: 15672
          resources: {}
      restartPolicy: Always

服务:

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
spec:
  ports:
    - name: "5672"
      port: 5672
      targetPort: 5672
    - name: "15672"
      port: 15672
      targetPort: 15672
  selector:
    app: rabbitmq

入口文件

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules: 
  - http:
      paths:
      - path: /rabbitmq
        pathType: Prefix
        backend:
          service:
            name: rabbitmq
            port:
              number: 15672

当我在浏览器中输入 http:///localhost/rabbitmq 时,我收到了这个 nginx 错误:{"error":"Object Not Found","re​​ason":"Not Found"}

但是当我进入其他 pod 并输入:curl http://rabbitmq:15672 它得到了网站的响应。

我是 kubernetes 的新手,我还没有找到任何相关的解决方案,如果有人能帮助我,我将不胜感激!!

感谢阅读。

尝试:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx  # <-- assumed you only have 1 ingress-nginx
  rules: 
  - http:
      paths:
      - path: /rabbitmq(/|$)(.*)
        ...

http://localhost/rabbitmq 的请求将被您的 rabbitmq 服务视为 /