Kubernetes LoadBalancer with new IP per service from LAN DHCP

6/23/2018

i am trying out Kubernetes on bare-metal, as a example I have docker containers exposing port 2002 (this is not HTTP).

I do not need to load balance traffic among my pods since each of new pod is doing its own jobs not for the same network clients.

Is there a software that will allow to access each new created service with new IP from internal DHCP so I can preserve my original container port?

I can create service with NodePort and access this pod by some randomly generated port that is forwarded to my 2002 port.

But i need to preserve that 2002 port while accessing my containers.

Each new service would need to be accessible by new LAN IP but with the same port as containers.

Is there some network plugin (LoadBalancer?) that will allow to forward from IP assigned by DHCP back to this randomly generated service port so I can access containers by original ports?

-- marek
ip
kubernetes
networking

1 Answer

6/23/2018

Starting service in Kubernetes, and then accessing this service with IP:2002, then starting another service but the same container image as previous, and then accessing it with another_new_IP:2002

Ah, that happens automatically within the cluster -- each Pod has its own IP address. I know you said bare metal, but this post by Lyft may give you some insight into how you can skip or augment the SDN and surface the Pod's IPs into routable address space, doing exactly what you want.

In more real terms: I haven't ever had the need to attempt such a thing, but CNI is likely flexible enough to interact with a DHCP server and pull a Pod's IP from a predetermined pool, so long as the pool is big enough to accommodate the frequency of Pod creation and termination.

Either way, I would absolutely read a blog post describing your attempt -- successful or not -- to pull this off!


On a separate note, be careful because the word Service means something specific within kubernetes, even though it is regrettably a word often used in a more generic term (as I suspect you did). Thankfully, a Service is designed to do the exact opposite of what you want to happen, so there was little chance of confusion -- just be aware.

-- mdaniel
Source: StackOverflow