feat(minecraft-router) add automatic mc service discovery to minecraft-router (#38128)

Add auto discovery with annotations for minecraft-router to find all
minecraft-java instances.

⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [X] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code
- [X] 📜 Documentation Changes

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [X] ⚖️ My code follows the style guidelines of this project
- [X] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [X] 📄 I have made changes to the documentation
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [X] ⬆️ I increased versions for any altered app according to semantic
versioning
- [X] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or
`fix(docs):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
This commit is contained in:
Xstar97TheNoob
2025-08-09 13:44:20 -04:00
committed by GitHub
parent c907bc19c9
commit 4bc53d7917
3 changed files with 49 additions and 6 deletions

View File

@@ -37,5 +37,4 @@ sources:
- https://github.com/truecharts/charts/tree/master/charts/stable/minecraft-router
- https://hub.docker.com/r/itzg/mc-router
type: application
version: 2.4.1
version: 2.5.0

View File

@@ -10,6 +10,8 @@ Default server can be given in the case an unknown URL is detected.
More information about linking charts and Cluster Internal Domain can be found in the common documentation.
Example deployment, used with Cluster Internal Domain names:
## Manual Discovery
```yaml
mcrouter:
default: minecraft-java.minecraft-java.svc.cluster.local:25565
@@ -18,3 +20,18 @@ mcrouter:
- ${SERVER2_URL}=truecharts-mcserver-minecraft-java.truecharts-mcserver.svc.cluster.local:25565
- ${SERVER3_URL}=kidsplayground-server-minecraft-java.kidsplayground-server.svc.cluster.local:25565
````
## Automatic Discovery
You can add the following annotations to your minecraft-java instances like so for the main service to be auto discovered by minecraft-router.
```yaml
service:
main:
enabled: true
annotations:
# only 1 service should have this enabled
mc-router.itzg.me/defaultServer: "true"
# the domain that users will connect to!
mc-router.itzg.me/externalServerName: "external.host.domain"
```

View File

@@ -14,11 +14,13 @@ service:
enabled: true
port: 25564
# manual option
mcrouter:
default: vanilla:25565
mappings:
- vanilla:25565
- forge:25565
# vanilla:25565
default: ""
mappings: []
# - vanilla:25565
# - forge:25565
workload:
main:
@@ -44,5 +46,30 @@ workload:
env:
API_BINDING: ":{{ .Values.service.api.ports.api.port }}"
PORT: "{{ .Values.service.main.ports.main.port }}"
# enabled for auto discovery to work
IN_KUBE_CLUSTER: true
# leave blank for all namespaces
# KUBE_NAMESPACE: ""
DEFAULT: "{{ .Values.mcrouter.default }}"
MAPPING: '{{ join "," .Values.mcrouter.mappings }}'
rbac:
main:
enabled: true
primary: true
clusterWide: true
rules:
- apiGroups: [""]
resources:
- "services"
verbs:
- "list"
- "watch"
serviceAccount:
main:
enabled: true
primary: true
podOptions:
automountServiceAccountToken: true