Share same IP for multiple pods

1/1/2018

Is it possible to expose pods application of different ports on single IP on different port for example that

microservices-cart       LoadBalancer   10.15.251.89    35.195.135.146   80:30721/TCP  
microservices-comments   LoadBalancer   10.15.249.230   35.187.190.124   80:32082/TCP  
microservices-profile    LoadBalancer   10.15.244.188   35.195.255.183   80:31032/TCP     

would look like

microservices-cart       LoadBalancer   10.15.251.89    35.195.135.146   80:30721/TCP  
microservices-comments   LoadBalancer   10.15.249.230   35.195.135.146   81:32082/TCP  
microservices-profile    LoadBalancer   10.15.244.188   35.195.135.146   82:31032/TCP     
-- Rok Jaklič
cloud
kubernetes

3 Answers

1/1/2018

Reusing the same external IP is usually accomplished by using ingress resources.

See https://kubernetes.io/docs/concepts/services-networking/ingress/

But you'll have to route with paths instead of ports.

-- navicore
Source: StackOverflow

1/2/2018

One possible solution is to combine NodePort and a reverse proxy. NodePort expose pods on different ports on all nodes. The reverse proxy serves as the entrance and redirects traffic to nodes.

-- ccshih
Source: StackOverflow

1/2/2018

One way or another you'll have to consolidate onto the same pod.

You can create a deployment that proxies each of the ports to the appropriate service. There are plenty of ways to create a TCP proxy - via nginx, node via package, there's a Go package maintained by Google; whatever you're most comfortable with.

-- Lev Kuznetsov
Source: StackOverflow