How to get two ingress ports accessible for single service using NGINX kubernetes controller

2/5/2019

We have one service which has two exposed ports- one is for server and second is for management. Kubernetes cluster have NGINX controller running. Is there any way to expose both the ports of service in Ingress YAML file? Details: Service server Port : 8081 Service Management Port: 8082 We tried with two "backends" in Ingress YAML file but it works only for default port which is 80 and fail for any other port. ingress.yml file is as below:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: bw-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
   - host: my.host.net
     http:
      paths:
      - path: "/controller/"
        backend:
          serviceName: bw-svc1
          servicePort: 80
       - path: "/actuator/"
         backend:
           serviceName: bw-svc2
           servicePort: 5612
-- Rahul
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

2/5/2019

The indentation level of both paths is not equal in your config sample.

Other than that your config looks correct and should result in the following behavior:

  1. All traffic coming to the cluster via my.host.net/controller will be sent to service bw-svc1:80
  2. All traffic coming to the cluster via my.host.net/actuator will be sent to service bw-svc2:5612

If this is not what you'd like to achieve, could you please re-phrase your question?

-- Bernard Halas
Source: StackOverflow