Deploy multiple LoadBalancer services sharing one NodeBalancer

I have been exploring using LKE to replace single node docker systems I have. I have ingress working and LKE spins up a NodBalancer for that and it works well.

I have a few services which do not talk HTTP and therefore don't play nice with the ingress pattern. Examples are Minecraft servers and VPN like wireguard.

I discovered I can expose those services as LoadBalancer types and LKE will spin up a NodeBalancer, but it seems to do a new one for each service I define. Is there some way to have it share the same NodeBalancer as long as each service uses unique ports?

I realize I could just run them as NodePort but then I have to pay attention to which node they are running on, which takes me back to my current single node Docker pattern and makes using k8s in general less desirable.

Ultimately what I want is to be able to expose a IP and map a number of my services to that IP on different ports, irregardless of what node they are running on.

1 Reply

Hi there,

I definitely understand your desire to use one NodeBalancer to provide ingress to multiple services within your cluster. While I must admit I'm not an expert in all of the intricacies of Kubernetes, I was able to achieve similar results using a workaround involving ConfigMaps and the NGINX Ingress Controller.

I suppose for some clarity it may be worth mentioning that the Loadbalancer service is an extension of the NodePort service which is an extension of the ClusterIP service. That is to say, when you create a LoadBalancer service by default a NodePort and ClusterIP are created as well, though not publicly facing.

While researching this subject I found this extremely useful post on StackOverflow that provides multiple methods of achieving your goal. Essentially, you can create ConfigMaps and patch the NGINX Ingress Controller to connect multiple services including non-HTTP(s) traffic.

To test this I used Helm to deploy a Minecraft chart and a WordPress application to my LKE cluster, I then followed the steps in the StackOverflow post to expose access to the additional services via one NodeBalancer. After exposing the services I was then able to connect to them from outside the cluster all using the same public IP address.

It's worth noting that all of the traffic that I tested this workaround with utilized TCP, from the best of my knowledge I believe that you may in fact need to utilize separate loadbalancer services for TCP and UDP traffic.

Hope this helps get you pointed in the right direction.

-- BD.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct