Kubernetes nginx ingress rabbitmq management and kibana

纵饮孤独 提交于 2021-02-18 11:28:12

问题


On my AKS cluster I have a Nginx ingress controller that I used to reverse proxy my kibana service running on the AKS. I want to however add another http services through the ingress, rabbitmq management console.

I'm unable to get both to work with the following configuration:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-aegis
  namespace: dev
  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rewrite-target: /    
spec:
  tls:
  - hosts:
    - dev.endpoint.net
    secretName: dev-secret   
  rules:
  - host: dev.endpoint.net
    http:
      paths:
      - path: /
        backend:
          serviceName: kibana-kibana
          servicePort: 5601
      - path: /rabbit
        backend:
          serviceName: rabbitmq
          servicePort: 15672

The Kibana works fine at root however RabbitMQ fails to load with a 503 with any path except /. If RabbitMQ's path is / then it works fine but then Kibana won't run.

I assume this is because internally they are sitting on the root aka localhost:15672 so it redirects to / on dev.endpoint.net.

How do I have multiple services like Kibana and RabbitmQ running from one endpoint?


回答1:


What you need to do is set the basePath for kibana to /kibana

See the below url

https://www.elastic.co/guide/en/kibana/current/settings.html

You are looking to configure server.basePath to /kibana. Then this will sort the reverse proxying issues and you can keep the MQ one directly on root /

You can also set SERVER_BASEPATH environment variable in your kibana pod and it will automatically pick the base path from that variable




回答2:


One idea would be to do host name based rules to switch backends. However, this would require a wildcard or SAN SSL certificate.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-aegis
  namespace: dev
  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rewrite-target: /    
spec:
  tls:
  - hosts:
    - dev.endpoint.net
    - rabbit.endpoint.net
    secretName: dev-secret   
  rules:
  - host: dev.endpoint.net
    http:
      paths:
      - path: /
        backend:
          serviceName: kibana-kibana
          servicePort: 5601
  - host: rabbit.endpoint.net
    http:
      paths:
      - path: /
        backend:
          serviceName: rabbitmq



回答3:


For RabbitMQ Management UI via ingress, set the following in the rabbitmq.conf file (you can use configmaps and mount the file inside the pod)

management.path_prefix = /rabbit

In the Ingress set the following :

...
   path: /rabbit(/|$)(.*)
...

See : https://www.rabbitmq.com/management.html#path-prefix



来源:https://stackoverflow.com/questions/56723867/kubernetes-nginx-ingress-rabbitmq-management-and-kibana

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!