I have the following services hosted in my Kubernetes cluster on AWS.
Both are working great. I currently have both of them set to type: LoadBalancer
, so they both have Elastic Load Balancers that are providing ingress to the cluster.
I would like to have only one ELB -- they cost money, and there's no reason not to have the Minecraft server and the HTTP(S) server on the same external IP.
I tried to create a service without a selector, then tried to manually create an Endpoints object referencing that service, but it doesn't appear to be working. Here's the setup on a gist. When I try and curl
on the allocated nodePort
from inside the cluster it just hangs.
Is there a way to have one service balance to multiple services?
The Ingress resource, which was added in version 1.1.0, was designed specifically for this use case. It allows you to put multiple services behind a single IP address, routing to them based on HTTP path. Check out the user guide on it for more details, but feel free to ask if you have more questions about it!
edit: For a non-HTTP(S) service, you can have to find a way to make sure all necessary ports get load balanced by the ELB and then properly routed by Kubernetes. On GCE, you could manually create the load balancer with the ports you need, and then put the load balancer's IP in the externalIPs
field for each service. My memory's a little fuzzy, but I don't believe that'll work with an ELB due to its packet rewriting. You might instead want to create each service as a NodePort
service, then configure your ELB to forward the packets from the correct external port to the node port for each service.
You could also simply use nginx as a proxy for your minecraft server, and forward traffic from ingress port 25565 to the minecraft server. That way all traffic goes through one Service
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With