2022-02-16 17:56:18 +00:00
|
|
|
job "mysql-server" {
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
type = "service"
|
2022-09-26 23:40:25 +00:00
|
|
|
priority = 80
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
2023-03-02 19:00:45 +00:00
|
|
|
port "envoy_metrics" {
|
|
|
|
to = 9123
|
|
|
|
}
|
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
|
2023-03-02 19:00:45 +00:00
|
|
|
|
|
|
|
config {
|
|
|
|
envoy_prometheus_bind_addr = "0.0.0.0:9123"
|
|
|
|
}
|
2022-03-14 22:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sidecar_task {
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 50
|
|
|
|
}
|
|
|
|
}
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
2023-03-02 19:00:45 +00:00
|
|
|
|
|
|
|
meta {
|
|
|
|
envoy_metrics_addr = "${NOMAD_ADDR_envoy_metrics}"
|
|
|
|
}
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
task "mysql-server" {
|
|
|
|
driver = "docker"
|
|
|
|
|
2022-07-25 22:51:41 +00:00
|
|
|
config {
|
2022-11-10 19:15:58 +00:00
|
|
|
image = "mariadb:10"
|
2022-07-25 22:51:41 +00:00
|
|
|
ports = ["db"]
|
2022-11-12 00:21:47 +00:00
|
|
|
args = ["--innodb-buffer-pool-size=1G"]
|
2022-07-25 22:51:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vault {
|
|
|
|
policies = [
|
|
|
|
"access-tables",
|
|
|
|
"nomad-task",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
volume_mount {
|
|
|
|
volume = "mysql-data"
|
|
|
|
destination = "/var/lib/mysql"
|
|
|
|
read_only = false
|
|
|
|
}
|
|
|
|
|
|
|
|
env = {
|
2022-02-17 22:03:42 +00:00
|
|
|
# Allow connections from any host
|
2022-02-16 17:56:18 +00:00
|
|
|
"MYSQL_ROOT_HOST" = "%"
|
|
|
|
}
|
|
|
|
|
2022-07-25 22:51:41 +00:00
|
|
|
template {
|
|
|
|
data = <<EOH
|
|
|
|
{{ with secret "kv/data/mysql" }}
|
2022-07-25 23:29:43 +00:00
|
|
|
MYSQL_ROOT_PASSWORD={{ .Data.data.root_password }}
|
2022-07-25 22:51:41 +00:00
|
|
|
{{ end }}
|
|
|
|
EOH
|
|
|
|
destination = "secrets/db.env"
|
|
|
|
env = true
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
2022-02-17 22:03:42 +00:00
|
|
|
cpu = 300
|
2022-02-16 17:56:18 +00:00
|
|
|
memory = 1024
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|