In Nomad you would probably use Consul to discover the address of the database and Vault to retrieve the database credentials. A Wordpress job file might look something like:
job "wordpress" {
datacenters = ["dc1"]
group "wordpress" {
# Scale count to handle your expected traffic
count = 2
task "wordpress" {
driver = "docker"
config {
image = "wordpress:latest"
port_map {
http = 80
}
}
resources {
cpu = 500 # 500 MHz
memory = 256 # 256MB
network {
mbits = 10
port "http" {
static = "8000"
}
}
}
service {
name = "wordpress"
port = "http"
check {
name = "alive"
type = "http"
interval = "10s"
timeout = "2s"
}
}
# env = true requires Nomad 0.6
template {
data = <<EOF
WORDPRESS_DB_HOST={{ key "service/mysql" }}
{{ with secret "database/creds/mysql" }}
WORDPRESS_DB_USER={{ .Data.username }}
WORDPRESS_DB_PASSWORD={{ .Data.password }}
EOF
change_mode = "restart"
env = true
}
vault {
policies = ["database"]
change_mode = "signal"
change_signal = "SIGHUP"
}
}
}
}
Note that to configure Wordpress via environment variables requires some recent additions to Nomad, so you'll either need to build from master or wait for the upcoming 0.6 release. You could use the
env stanza to hardcode the username and password, but discourage that because it's hard to keep that secure.
It's more involved to setup Wordpress+MySQL in Nomad, but you have much greater flexibility and a lot more features available.
Hope that helps!