diff --git a/README.md b/README.md index c915814..21d1357 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Routes Minecraft client connections to backend servers based upon the requested server address. -## Usage +# Usage ```text Flags: @@ -15,11 +15,10 @@ Flags: --port=25565 The port bound to listen for Minecraft client connections --api-binding=API-BINDING The host:port bound for servicing API requests - --mapping=MAPPING ... Mapping of external hostname to internal server - host:port + --mapping=MAPPING,MAPPING Where MAPPING is externalHostname=host:port ``` -## REST API +# REST API * `GET /routes` Retrieves the currently configured routes @@ -41,6 +40,28 @@ Flags: * `DELETE /routes/{serverAddress}` Deletes an existing route for the given `serverAddress` +# Docker Compose Usage + +The following diagram shows how [the example docker-compose.yml](docs/docker-compose.yml) +configures two Minecraft server services named `vanilla` and `forge`, which also become the internal +network aliases. _Notice those services don't need their ports exposed since the internal +networking allows for the inter-container access._ + +The `router` service is only one of the services that needs to exposed on the external +network. The `--mapping` declares how the hostname users will enter into their Minecraft client +will map to the internal services. + +![](docs/compose-diagram.png) + +To test out this example, I added these two entries to my "hosts" file: + +``` +127.0.0.1 vanilla.example.com +127.0.0.1 forge.example.com +``` + +# Kubernetes Usage + ## Using kubernetes service auto-discovery When running `mc-router` as a kubernetes pod and you pass the `--in-kube-cluster` command-line argument, then diff --git a/docs/compose-diagram.png b/docs/compose-diagram.png new file mode 100644 index 0000000..e9ec1e0 Binary files /dev/null and b/docs/compose-diagram.png differ diff --git a/docs/compose-diagram.svg b/docs/compose-diagram.svg new file mode 100644 index 0000000..1fee0d5 --- /dev/null +++ b/docs/compose-diagram.svg @@ -0,0 +1,496 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + External hostnames + + + + + diff --git a/docs/docker-compose.yml b/docs/docker-compose.yml new file mode 100644 index 0000000..90de42d --- /dev/null +++ b/docs/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.4' + +services: + vanilla: + image: itzg/minecraft-server + environment: + EULA: "TRUE" + forge: + image: itzg/minecraft-server + environment: + EULA: "TRUE" + TYPE: FORGE + router: + image: itzg/mc-router + ports: + - 25565:25565 + command: --mapping=vanilla.example.com=vanilla:25565,forge.example.com=forge:25565 + diff --git a/docs/k8s-mc-with-default.yaml b/docs/k8s-mc-with-default.yaml index 1b518d6..cbcc271 100644 --- a/docs/k8s-mc-with-default.yaml +++ b/docs/k8s-mc-with-default.yaml @@ -4,10 +4,13 @@ kind: Service metadata: name: mc-stable annotations: - "mc-router.itzg.me/defaultServer": "mc.your.domain" + "mc-router.itzg.me/defaultServer": "true" spec: + type: ClusterIP ports: - - port: 25565 + - port: 25566 + name: mc-router + targetPort: 25565 selector: run: mc-stable ---