homelab-nomad/databases/mysql.nomad

83 lines
1.4 KiB
Plaintext
Raw Normal View History

2022-02-16 17:56:18 +00:00
job "mysql-server" {
datacenters = ["dc1"]
type = "service"
group "mysql-server" {
count = 1
restart {
attempts = 10
interval = "5m"
delay = "25s"
mode = "delay"
}
network {
mode = "bridge"
port "db" {
2022-05-10 04:45:08 +00:00
host_network = "loopback"
2022-02-17 22:03:42 +00:00
to = 3306
2022-02-16 17:56:18 +00:00
}
}
volume "mysql-data" {
type = "host"
read_only = false
source = "mysql-data"
}
service {
name = "mysql-server"
port = "db"
connect {
2022-03-14 22:58:03 +00:00
sidecar_service {
proxy {
local_service_port = 3306
}
}
sidecar_task {
resources {
cpu = 50
memory = 50
}
}
2022-02-16 17:56:18 +00:00
}
2022-02-17 22:03:42 +00:00
# Can't use a tcp check with bridge network or proxy
2022-02-16 17:56:18 +00:00
# check {
# type = "tcp"
# interval = "10s"
# timeout = "2s"
# }
}
task "mysql-server" {
driver = "docker"
volume_mount {
volume = "mysql-data"
destination = "/var/lib/mysql"
read_only = false
}
env = {
"MYSQL_ROOT_PASSWORD" = "supersecretpassword"
2022-02-17 22:03:42 +00:00
# Allow connections from any host
2022-02-16 17:56:18 +00:00
"MYSQL_ROOT_HOST" = "%"
}
config {
image = "mysql:8"
ports = ["db"]
}
resources {
2022-02-17 22:03:42 +00:00
cpu = 300
2022-02-16 17:56:18 +00:00
memory = 1024
}
}
}
}