Minecraft refactor: dynamic routes, separate jobs (#59)
refactors minecraft jobs allowing for more flexibility in the future (e.g. adding an rcon web interface): - split `minecraft.hcl` into multiple job files - update ports used - add consul service attached to mc and rcon ports - remove `gate-proxy.hcl` static configuration - it is now consul aware via a consul template - add fallback route on `gate-proxy` with message to inform users - remove unused jobs - move all minecraft jobs to use template blocks instead of env blocks for envvars - this lets us define the `RCON_PASSWORD` and store it in consul
This commit is contained in:
parent
e67953631c
commit
fe6f66754d
7 changed files with 300 additions and 316 deletions
|
@ -1,279 +0,0 @@
|
|||
job "minecraft" {
|
||||
datacenters = ["aperture"]
|
||||
type = "service"
|
||||
|
||||
group "vanilla-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc-vanilla-port" {
|
||||
static = 25567
|
||||
to = 25565
|
||||
}
|
||||
port "mc-vanilla-rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "vanilla-mc"
|
||||
}
|
||||
|
||||
task "minecraft-vanilla" {
|
||||
driver = "docker"
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc-vanilla-port","mc-vanilla-rcon"]
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 8192 # 8GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
ICON = "https://docs.redbrick.dcu.ie/assets/logo.png"
|
||||
USE_AIKAR_FLAGS=true
|
||||
MOTD = "LONG LIVE THE REDBRICK"
|
||||
MAX_PLAYERS = "20"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group "fugitives-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc-fugitives-port" {
|
||||
static = 25570
|
||||
to = 25565
|
||||
}
|
||||
port "mc-fugitives-rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "fugitives-mc"
|
||||
}
|
||||
|
||||
task "minecraft-fugitives" {
|
||||
driver = "docker"
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc-fugitives-port","mc-fugitives-rcon"]
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 8192 # 8GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
USE_AIKAR_FLAGS=true
|
||||
MOTD = "Fugitives"
|
||||
MAX_PLAYERS = "20"
|
||||
MEMORY = "6G"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group "games-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc-games-port" {
|
||||
static = 25569
|
||||
to = 25565
|
||||
}
|
||||
|
||||
port "mc-games-rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "games-mc"
|
||||
}
|
||||
|
||||
task "minecraft-games" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc-games-port","mc-games-rcon"]
|
||||
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 8192 # 8GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "PURPUR"
|
||||
VERSION = "1.20.1"
|
||||
MOTD = "DCU Games Soc Minecraft Server"
|
||||
USE_AIKAR_FLAGS=true
|
||||
OPS = ""
|
||||
MAX_PLAYERS = "20"
|
||||
}
|
||||
}
|
||||
}
|
||||
group "olim909-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc-olim909-port" {
|
||||
static = 25568
|
||||
to = 25565
|
||||
}
|
||||
|
||||
port "mc-olim909-rcon" {
|
||||
to = 25575
|
||||
}
|
||||
port "mc-olim909-geyser" {
|
||||
to = 19132
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "olim909-mc"
|
||||
}
|
||||
|
||||
task "minecraft-olim909" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc-olim909-port","mc-olim909-rcon","mc-olim909-geyser"]
|
||||
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 4096 # 4GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
VERSION = "1.20.4"
|
||||
USE_AIKAR_FLAGS=true
|
||||
OPS = "Olim909"
|
||||
MAX_PLAYERS = "5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group "regaus-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc-regaus-port" {
|
||||
static = 25566
|
||||
to = 25565
|
||||
}
|
||||
|
||||
port "mc-regaus-rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "regaus-mc"
|
||||
}
|
||||
|
||||
task "minecraft-regaus" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc-regaus-port","mc-regaus-rcon"]
|
||||
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 4096 # 4GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
VERSION = "1.20.4"
|
||||
USE_AIKAR_FLAGS=true
|
||||
OPS = "regaus"
|
||||
MAX_PLAYERS = "5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group "cjaran-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc-cjaran-port" {
|
||||
static = 25571
|
||||
to = 25565
|
||||
}
|
||||
|
||||
port "mc-cjaran-rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "cjaran-mc"
|
||||
}
|
||||
|
||||
task "minecraft-cjaran" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc-cjaran-port","mc-cjaran-rcon"]
|
||||
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 4096 # 4GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
ICON = "https://i.imgur.com/HC9cRNf.png"
|
||||
VERSION = "1.20.4"
|
||||
USE_AIKAR_FLAGS=true
|
||||
OPS = "BloThen"
|
||||
MAX_PLAYERS = "10"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
61
jobs/games/minecraft/cjaran.hcl
Normal file
61
jobs/games/minecraft/cjaran.hcl
Normal file
|
@ -0,0 +1,61 @@
|
|||
job "minecraft-cjaran" {
|
||||
datacenters = ["aperture"]
|
||||
type = "service"
|
||||
|
||||
group "cjaran-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc" {
|
||||
to = 25565
|
||||
}
|
||||
|
||||
port "rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "cjaran-mc"
|
||||
port = "mc"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "cjaran-mc-rcon"
|
||||
port = "rcon"
|
||||
}
|
||||
|
||||
task "minecraft-cjaran" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc", "rcon"]
|
||||
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 4096 # 4GB
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
VERSION = "1.20.4"
|
||||
USE_AIKAR_FLAGS = true
|
||||
OPS = "BloThen"
|
||||
MAX_PLAYERS = "10"
|
||||
ENABLE_RCON = true
|
||||
RCON_PASSWORD = {{ key "games/mc/cjaran-mc/rcon/password" }}
|
||||
EOF
|
||||
destination = "local/.env"
|
||||
env = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
jobs/games/minecraft/fugitives.hcl
Normal file
58
jobs/games/minecraft/fugitives.hcl
Normal file
|
@ -0,0 +1,58 @@
|
|||
job "minecraft-fugitives" {
|
||||
datacenters = ["aperture"]
|
||||
type = "service"
|
||||
|
||||
group "fugitives-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc" {
|
||||
to = 25565
|
||||
}
|
||||
port "rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "fugitives-mc"
|
||||
port = "mc"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "fugitives-mc-rcon"
|
||||
port = "rcon"
|
||||
}
|
||||
|
||||
task "minecraft-fugitives" {
|
||||
driver = "docker"
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc", "rcon"]
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 8192 # 8GB
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
USE_AIKAR_FLAGS = true
|
||||
MOTD = "Fugitives"
|
||||
MAX_PLAYERS = "20"
|
||||
MEMORY = "6G"
|
||||
ENABLE_RCON = true
|
||||
RCON_PASSWORD = {{ key "games/mc/fugitives-mc/rcon/password" }}
|
||||
EOF
|
||||
destination = "local/.env"
|
||||
env = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
62
jobs/games/minecraft/games.hcl
Normal file
62
jobs/games/minecraft/games.hcl
Normal file
|
@ -0,0 +1,62 @@
|
|||
job "minecraft-games" {
|
||||
datacenters = ["aperture"]
|
||||
type = "service"
|
||||
|
||||
group "games-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc" {
|
||||
to = 25565
|
||||
}
|
||||
|
||||
port "rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "games-mc"
|
||||
port = "mc"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "games-mc-rcon"
|
||||
port = "rcon"
|
||||
}
|
||||
|
||||
task "minecraft-games" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc", "rcon"]
|
||||
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 8192 # 8GB
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
EULA = "TRUE"
|
||||
TYPE = "PURPUR"
|
||||
VERSION = "1.20.1"
|
||||
MOTD = "DCU Games Soc Minecraft Server"
|
||||
USE_AIKAR_FLAGS = true
|
||||
OPS = ""
|
||||
MAX_PLAYERS = "20"
|
||||
ENABLE_RCON = true
|
||||
RCON_PASSWORD = {{ key "games/mc/games-mc/rcon/password" }}
|
||||
EOF
|
||||
destination = "local/.env"
|
||||
env = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,28 +6,40 @@ job "minecraft-magma" {
|
|||
count = 1
|
||||
|
||||
network {
|
||||
port "minecraft" {
|
||||
static = 25572
|
||||
to = 25565
|
||||
port "mc" {
|
||||
to = 25565
|
||||
}
|
||||
port "rcon" {
|
||||
to = 25575
|
||||
}
|
||||
port "voicechat" {
|
||||
to = 24454
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "minecraft-magma"
|
||||
port = "minecraft"
|
||||
name = "magma-mc"
|
||||
port = "mc"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "magma-mc-rcon"
|
||||
port = "rcon"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "magma-mc-voice"
|
||||
port = "voice"
|
||||
tags = [
|
||||
"traefik.enable=true",
|
||||
"traefik.tcp.routers.magma-mc-voice.rule=HostSNI(`magma-mc.rb.dcu.ie`)",
|
||||
"traefik.tcp.routers.magma-mc-voice.tls.passthrough=true",
|
||||
"traefik.udp.routers.magma-mc-voice.entrypoints=voice-udp",
|
||||
]
|
||||
}
|
||||
|
||||
task "minecraft-magma" {
|
||||
driver = "docker"
|
||||
config {
|
||||
image = "itzg/minecraft-server:java17-alpine"
|
||||
ports = ["minecraft", "rcon", "voicechat"]
|
||||
ports = ["mc", "rcon", "voice"]
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
|
@ -38,14 +50,20 @@ job "minecraft-magma" {
|
|||
memory = 10240 # 10GB
|
||||
}
|
||||
|
||||
env {
|
||||
EULA = "TRUE"
|
||||
TYPE = "FABRIC"
|
||||
VERSION = "1.20.4"
|
||||
ICON = "https://raw.githubusercontent.com/redbrick/design-system/main/assets/logos/logo.png"
|
||||
MEMORY = "8G"
|
||||
USE_AIKAR_FLAGS = true
|
||||
JVM_XX_OPTS = "-XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32"
|
||||
template {
|
||||
data = <<EOF
|
||||
EULA = "TRUE"
|
||||
TYPE = "FABRIC"
|
||||
VERSION = "1.20.4"
|
||||
ICON = "https://raw.githubusercontent.com/redbrick/design-system/main/assets/logos/logo.png"
|
||||
MEMORY = "8G"
|
||||
USE_AIKAR_FLAGS = true
|
||||
JVM_XX_OPTS = "-XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32"
|
||||
ENABLE_RCON=true
|
||||
RCON_PASSWORD = {{{ key "games/mc/magma-mc/rcon/password" }}
|
||||
EOF
|
||||
destination = "local/.env"
|
||||
env = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
59
jobs/games/minecraft/vanilla.hcl
Normal file
59
jobs/games/minecraft/vanilla.hcl
Normal file
|
@ -0,0 +1,59 @@
|
|||
job "minecraft-vanilla" {
|
||||
datacenters = ["aperture"]
|
||||
type = "service"
|
||||
|
||||
group "vanilla-mc" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "mc" {
|
||||
to = 25565
|
||||
}
|
||||
port "rcon" {
|
||||
to = 25575
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "vanilla-mc"
|
||||
port = "mc"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "vanilla-mc-rcon"
|
||||
port = "rcon"
|
||||
}
|
||||
|
||||
task "minecraft-vanilla" {
|
||||
driver = "docker"
|
||||
config {
|
||||
image = "itzg/minecraft-server"
|
||||
ports = ["mc", "rcon"]
|
||||
volumes = [
|
||||
"/storage/nomad/${NOMAD_TASK_NAME}:/data"
|
||||
]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 3000 # 3000 MHz
|
||||
memory = 8192 # 8GB
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
EULA = "TRUE"
|
||||
TYPE = "PAPER"
|
||||
VERSION = "1.21.1"
|
||||
ICON = "https://docs.redbrick.dcu.ie/assets/logo.png"
|
||||
USE_AIKAR_FLAGS = true
|
||||
MOTD = "LONG LIVE THE REDBRICK"
|
||||
MAX_PLAYERS = "20"
|
||||
ENABLE_RCON = true
|
||||
RCON_PASSWORD = {{ key "games/mc/vanilla-mc/rcon/password" }}
|
||||
EOF
|
||||
destination = "local/.env"
|
||||
env = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ job "gate-proxy" {
|
|||
|
||||
network {
|
||||
port "mc" {
|
||||
static = 4501
|
||||
static = 25565
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ job "gate-proxy" {
|
|||
ports = ["mc"]
|
||||
|
||||
volumes = [
|
||||
"local/file.conf:/config.yaml"
|
||||
"local/config.yaml:/config.yaml"
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ job "gate-proxy" {
|
|||
# settings are omitted and will be set by default.
|
||||
# See config.yml for the full configuration options.
|
||||
config:
|
||||
bind: 0.0.0.0:4501
|
||||
bind: 0.0.0.0:{{ env "NOMAD_PORT_mc" }}
|
||||
|
||||
forwarding:
|
||||
mode: legacy
|
||||
|
@ -48,24 +48,29 @@ config:
|
|||
lite:
|
||||
enabled: true
|
||||
routes:
|
||||
- host: regaus.rb.dcu.ie
|
||||
backend: regaus-mc.service.consul:25566
|
||||
- host: mc.rb.dcu.ie
|
||||
backend: vanilla-mc.service.consul:25567
|
||||
- host: olim909.rb.dcu.ie
|
||||
backend: olim909-mc.service.consul:25568
|
||||
- host: olim909-geyser.rb.dcu.ie
|
||||
backend: olim909-mc.service.consul:19132
|
||||
- host: games.rb.dcu.ie
|
||||
backend: games-mc.service.consul:25569
|
||||
- host: fugitives.rb.dcu.ie
|
||||
backend: fugitives-mc.service.consul:25570
|
||||
- host: cjaran-mc.rb.dcu.ie
|
||||
backend: cjaran-mc.service.consul:25571
|
||||
- host: magma-mc.rb.dcu.ie
|
||||
backend: minecraft-magma.service.consul:25572
|
||||
# Consul template to generate routes
|
||||
# matches against all consul services ending in "-mc"
|
||||
# NOTE: each minecraft job must have both:
|
||||
# - a name ending in "-mc"
|
||||
# - a port attached to the service
|
||||
{{- range services }}
|
||||
{{- if .Name | regexMatch ".*-mc$" }}
|
||||
{{- range service .Name }}
|
||||
- host: {{ .Name }}.rb.dcu.ie
|
||||
backend: {{ .Name }}.service.consul:{{ .Port }}{{ end -}}{{ end -}}{{ end }}
|
||||
# Fallback route for when any service is unavailable
|
||||
- host: '*'
|
||||
backend: localhost:2000 # backend must exist - this is a dummy value
|
||||
fallback:
|
||||
motd: |
|
||||
§cThis server is offline/does not exist!
|
||||
§eCheck back later!
|
||||
version:
|
||||
name: '§cTry again later!'
|
||||
protocol: -1
|
||||
|
||||
EOH
|
||||
destination = "local/file.conf"
|
||||
destination = "local/config.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue