moorkop / mccy-engine

Provides a web based "Minecraft Server as a Service" (MCaaS?) to deploy Minecraft server containers on any Docker Swarm cluster or standalone Engine instance.
Apache License 2.0
12 stars 4 forks source link

Default the port field to next unused one #7

Closed itzg closed 8 years ago

itzg commented 8 years ago

Could at least look at the known (i.e. "mccy" labelled) ones and find next port >= 25565 not yet mapped.

itzg commented 8 years ago

After further thought, as part of 00a0004f23f5504a6471fe08ad3a3e902f829eff I decided to have containers use a host-selected port by default. Part of my reasoning was that on a multi-node Swarm cluster it's not obvious if a port is available on any one of the nodes...until you start up the container and Swarm can check for sure.

sshipway commented 8 years ago

If the API bit is abstracted out, and an option made to allow it to talk Rancher rather than Swarm, then Rancher is capable of using a small utility container that acts as a load balancer, and will run on a subset of the cluster forwarding out packets to the actual host running the container we want. The practical upshot of this is that the minecraft container exposes no ports at all to the public, and all the port handling is done by the LB which is running on a known host. An abstracted out 'start' function for Rancher would simply start up the Minceraft container anywhere in the cluster, then start up a dedicated LB with a known IP and server-selected port to point to it (I've actually created a Rancher 'catalogue item' that does this as a one-off with a couple of configurable options)

itzg commented 8 years ago

Very interesting. Can you point me to more info about their LB?

That adds some more merit to going with server/host selected ports for the containers themselves.

sshipway commented 8 years ago

Their LB is a special lightweight container - rancher/agent-instance - that can do a number of things including load balancing. It is managed and started by the Rancher server automatically when you define a Load Balancer. When I get back into the office I can send you a dockerfile for how to call it to make it work with Minecraft. If you set up a small Rancher setup (run rancher/server somewhere, login to its web interface and it will give you the command to start the agent container on a new host) you can see it appearing when you define a load balancer in a Stack.