我开始用 nomad 做一些测试,我可以在最简单的方法上使用一些帮助来将网络添加到组任务中。基本上我的问题是:
在任务之间添加内部网络的最简单方法是什么?并且同一组中的任务不应该彼此具有默认访问权限吗?还是我做错了什么?
我有这个配置:
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" {}
}
}
}
}
}
我希望我的 app1 和 app2 可以在内部相互通信并与数据库通信。我已阅读有关传递给每个容器的游牧地址变量的信息,并且我试图建立连接,但连接被拒绝。是使用 connect 完成此行为的唯一方法吗?还是有更简单的方法?感谢帮助:)