I'm starting to do some tests with nomad and I could use a bit on help on the easiest way to add networking to a group task. Basically my questions are:
Which is the easiest way to add internal networking between tasks? and Shouldn't the tasks on the same group have default access to each other? Or there is something I'm doing wrong?
I have this configuration:
job "job" {
datacenters = [ "dc1" ]
type = "service"
group "group" {
count = 1
task "db" {
kill_timeout = "120s"
driver = "docker"
config {
image = "dbimage"
port_map {
db = 3306
}
}
env {
MYSQL_DATABASE = "db"
MYSQL_ROOT_PASSWORD = "pass"
}
service {
name = "db"
port = "db"
}
resources {
memory = 256
network {
mode = "host"
port "db" {}
}
}
}
task "app1" {
driver = "docker"
kill_timeout = "120s"
config {
image = "app1"
port_map {
app1 = 5000
}
}
service {
name = "app1"
port = "app1"
}
resources {
memory = 128
network {
mode = "host"
port "app1" {}
}
}
}
task "app2" {
driver = "docker"
kill_timeout = "120s"
config {
image = "app2:image"
port_map {
app2 = 4000
}
}
env {
.....
}
service {
name = "app2"
port = "app2"
}
resources {
memory = 256
network {
mode = "host"
port "app2" {}
}
}
}
}
}
and I would like that my app1 and app2 could talk internally to each other and to the db. I have read about the the nomad ADDRESS variables that are passed to each container and I tried to reach connectivity but I get connection refused. Is the only way to accomplish this behaviour with connect ? Or there is a simpler way? Appreciate the help :)