A few Nomad examples. Nomad is great and is worth considering as an alternative to k3s and docker compose.
Last active
April 21, 2023 19:36
-
-
Save jDmacD/e133671450f8003d3051737e8c43178d to your computer and use it in GitHub Desktop.
Hashicorp Nomad Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
job "argo" { | |
priority = 50 | |
datacenters = ["dc1"] | |
type = "service" | |
group "argo" { | |
count = 1 | |
task "argo-setup" { | |
lifecycle { | |
hook = "prestart" | |
sidecar = false | |
} | |
driver = "raw_exec" | |
template { | |
data = <<EOH | |
sysctl -w net.core.rmem_max=2500000 | |
EOH | |
destination = "setup.sh" | |
perms = "0744" | |
} | |
config { | |
command = "/bin/bash" | |
args = ["setup.sh"] | |
} | |
} | |
task "argo-up" { | |
driver = "raw_exec" | |
artifact { | |
source = "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${attr.cpu.arch}" | |
destination = "local/" | |
} | |
config { | |
command = "${NOMAD_TASK_DIR}/cloudflared-linux-${attr.cpu.arch}" | |
args = [ | |
"tunnel", | |
"--no-autoupdate", | |
"run", | |
"--token", | |
"<token here>", | |
] | |
} | |
resources { | |
cpu = 512 | |
memory = 1024 | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
job "minecraft" { | |
datacenters = ["dc1"] | |
type = "service" | |
group "bedrock-server" { | |
constraint { | |
attribute = "${attr.cpu.arch}" | |
operator = "=" | |
value = "amd64" | |
} | |
network { | |
port "udp" { | |
static = 19132 | |
} | |
} | |
service { | |
name = "bedrock" | |
port = "udp" | |
tags = [ | |
"traefik.enable=false", | |
"traefik.http.routers.bedrock.rule=Host(`bedrock.service.consul`) || Host(`bedrock.jtec.xyz`)" | |
] | |
} | |
task "bedrock-up" { | |
driver = "docker" | |
config { | |
image = "itzg/minecraft-bedrock-server" | |
ports = ["udp"] | |
mount { | |
type = "volume" | |
target = "/data" | |
source = "bedrock" | |
readonly = false | |
volume_options { | |
no_copy = false | |
driver_config { | |
name = "local" | |
options { | |
type = "nfs" | |
o = "nfsvers=4,addr=fileserver,rw" | |
device = ":/configs/minecraft/bedrock/data" | |
} | |
} | |
} | |
} | |
} | |
env { | |
EULA = "true" | |
SERVER_NAME = "BEDROCK" | |
ALLOW_CHEATS = "true" | |
ONLINE_MODE = "false" | |
ENABLE_LAN_VISIBILITY = "true" | |
} | |
resources { | |
cpu = 512 | |
memory = 1024 | |
} | |
} | |
} | |
group "papermc-server" { | |
network { | |
port "tcp" { | |
static = 25565 | |
} | |
} | |
service { | |
name = "papermc" | |
port = "tcp" | |
tags = [ | |
"traefik.enable=false", | |
"traefik.http.routers.papermc.rule=Host(`papermc.service.consul`)" | |
] | |
} | |
task "papermc-up" { | |
driver = "docker" | |
config { | |
image = "marctv/minecraft-papermc-server:latest" | |
ports = ["tcp"] | |
mount { | |
type = "volume" | |
target = "/data" | |
source = "papermc" | |
readonly = false | |
volume_options { | |
no_copy = false | |
driver_config { | |
name = "local" | |
options { | |
type = "nfs" | |
o = "nfsvers=4,addr=fileserver,rw" | |
device = ":/configs/minecraft/papermc/data" | |
} | |
} | |
} | |
} | |
} | |
env { | |
MEMORYSIZE = "2G" | |
TZ = "Europe/Dublin" | |
PAPERMC_FLAGS= "" | |
} | |
resources { | |
cpu = 2048 | |
memory = 2560 | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
traefik_version = "2.5.5" | |
} | |
job "routing" { | |
datacenters = ["dc1"] | |
type = "system" | |
priority = 90 | |
constraint { | |
attribute = "${attr.kernel.name}" | |
operator = "=" | |
value = "linux" | |
} | |
group "traefik" { | |
network { | |
port "http" { | |
static = 80 | |
to = 80 | |
} | |
port "https" { | |
static = 443 | |
to = 443 | |
} | |
port "ui" {} | |
port "ping" {} | |
} | |
service { | |
name = "traefik" | |
port = "https" | |
tags = [ | |
"traefik.enable=true", | |
"traefik.http.routers.api.service=api@internal", | |
"traefik.http.routers.api.entrypoints=websecure", | |
"traefik.http.routers.api.tls=true", | |
"traefik.http.routers.api.rule=Host(`traefik.service.consul`) && (PathPrefix(`/api/`) || PathPrefix(`/dashboard/`))" | |
] | |
check { | |
type = "http" | |
port = "ping" | |
path = "/ping" | |
interval = "30s" | |
timeout = "2s" | |
} | |
} | |
task "traefik-routing-up" { | |
driver = "raw_exec" | |
artifact { | |
source = "https://github.com/traefik/traefik/releases/download/v${local.traefik_version}/traefik_v${local.traefik_version}_linux_${attr.cpu.arch}.tar.gz" | |
} | |
config { | |
command = "${NOMAD_TASK_DIR}/traefik" | |
args = [ | |
"--ping=true", | |
"--entryPoints.ping.address=:${NOMAD_PORT_ping}", | |
"--ping.entryPoint=ping", | |
"--metrics.prometheus=true", | |
"--api.dashboard=8080", | |
"--api.insecure=false", | |
"--entryPoints.traefik.address=:${NOMAD_PORT_ui}", | |
"--entryPoints.web.address=:80", | |
"--entryPoints.websecure.address=:443", | |
"--providers.consulcatalog.refreshInterval=10s", | |
"--providers.consulcatalog.prefix=traefik", | |
"--providers.consulcatalog.requireConsistent=true", | |
"--providers.consulcatalog.endpoint.address=${attr.unique.network.ip-address}:8500", | |
] | |
} | |
resources { | |
cpu = 50 | |
memory = 50 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment