Add support for docker swarm service discovery (#103)

This commit is contained in:
n1xx1
2022-08-05 03:59:20 +02:00
committed by GitHub
parent de3c728d86
commit d15bc9e986
7 changed files with 432 additions and 598 deletions
+30
View File
@@ -24,6 +24,12 @@ Routes Minecraft client connections to backend servers based upon the requested
Use in-cluster Kubernetes config (env IN_KUBE_CLUSTER)
-kube-config string
The path to a Kubernetes configuration file (env KUBE_CONFIG)
-in-docker-swarm
Use in-swarm Docker config (env IN_DOCKER_SWARM)
-docker-timeout
Timeout configuration in seconds for the Docker Swarm integration (env DOCKER_TIMEOUT) (default 0)
-docker-refresh-interval
Refresh interval in seconds for the Docker Swarm integration (env DOCKER_REFRESH_INTERVAL) (default 15)
-mapping string
Comma-separated mappings of externalHostname=host:port (env MAPPING)
-metrics-backend string
@@ -185,6 +191,30 @@ rules:
verbs: ["watch","list","get","update"]
```
# Docker Swarm Usage
## Using Docker Swarm Service auto-discovery
When running `mc-router` in a Docker Swarm environment you can pass the `--in-docker-swarm`
command-line argument and it will poll the Docker API periodically to find all the running
services for minecraft instances. To enable discovery you have to set the `mc-router.host`
label on the service. These are the labels scanned:
- `mc-router.host`: Used to configure the hostname the Minecraft clients would use to
connect to the server. The service endpoint will be used as the routed backend. You can
use more than one hostname by splitting it with a comma.
- `mc-router.port`: This value must be set to the port the Minecraft server is listening on.
The default value is 25565.
- `mc-router.default`: Set this to a truthy value to make this server the deafult backend.
Please note that `mc-router.host` is still required to be set.
## Example Docker Swarm deployment
Refer to [this example docker-compose.yml](docs/swarm.docker-compose.yml) to see how to
configure two different Minecraft servers and a `mc-router` instance. Notice how you don't
have to expose the Minecraft instances ports, but all the containers are required to be in
the same network.
# Development
## Building locally with Docker