How to: Using Kubernetes Service auto-discovery
When running `mc-router` as a Kubernetes Pod and you pass the `--in-kube-cluster` command-line argument, then it will automatically watch for any services annotated with
- `mc-router.itzg.me/externalServerName` : The value of the annotation will be registered as the external hostname Minecraft clients would used to connect to the routed service. The service is used as the routed backend. You can use more hostnames by splitting them with comma or newline. Whitespace around commas is automatically trimmed. For example: `"host1.com,host2.com"`, `"host1.com, host2.com"`, or multi-line values.
- `mc-router.itzg.me/defaultServer` : When set to "true", the service is used as the default if no other `externalServiceName` annotations applies.

By default, the router will watch all namespaces for those services; however, a specific namespace can be specified using the `KUBE_NAMESPACE` environment variable. The pod's own namespace could be set using:

```yaml
     - name: KUBE_NAMESPACE
       valueFrom:
         fieldRef:
           fieldPath: metadata.namespace
```

For example, start `mc-router`'s container spec with

```yaml
image: itzg/mc-router
name: mc-router
args: ["--in-kube-cluster"]
```

and configure the backend minecraft server's service with the annotation:

```yaml
apiVersion: v1
kind: Service
metadata:
  name: mc-forge
  annotations:
    "mc-router.itzg.me/externalServerName": "external.host.name"
```

you can use multiple host names:

```yaml
apiVersion: v1
kind: Service
metadata:
  name: mc-forge
  annotations:
    "mc-router.itzg.me/externalServerName": "external.host.name,other.host.name"
```
or with newlines and optional whitespace:

```yaml
apiVersion: v1
kind: Service
metadata:
  name: mc-forge
  annotations:
    "mc-router.itzg.me/externalServerName": |
      external.host.name
      other.host.name
```

The `Role` or `ClusterRole` bound to the service account should have the rules:

```yaml
rules:
  - apiGroups: [""]
    resources: ["services"]
    verbs: ["watch","list"]
```

and if using StatefulSet auto-scaling additionally

```yaml
  - apiGroups: ["apps"]
    resources: ["statefulsets"]
    verbs: ["watch","list","get","update"]
  - apiGroups: ["apps"]
    resources: ["statefulsets/scale"]
    verbs: ["get","update"]
```