How to route port based o specific path in Kubernetes

7/5/2020

I have two services and use port forward to forward them in different prots of local host. For example service1 can be visited via localhost:port1, service2 can be visited via localhost:port2.

At some point during the workflow in service1, in service1 UI, a new link like "localhost:port1/_/path" is generate. But it actually works in service2 for that link. I can visit then link by changing port1 to port2 but I can't visit with the generated link. I mean I can visit "localhost:port2/_/path" other than "localhost:port1/_/path" which is generated by service1 backend. I want to do a port routing if path"_/path" is present in service1. How can I do that? I read the ingress documentation and can't find port routing examaples. Thanks!

-- Ally Qin
kubernetes
nginx-ingress
portforwarding
routes

1 Answer

7/6/2020

You need to deploy nginx ingress controller and setup path based routing. follow the link for reference

https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/ingress-path-matching.md

-- P Ekambaram
Source: StackOverflow