在Nomad(0.6)中部署Redis工作时,我无法在Consul中使其健康。
我在一个容器中启动Consul,并在localhost上使端口8500可用。
$ docker container run --name consul -d -p 8500:8500 consul
当我运行nomad时,它正确地连接到Consul,正如我们在日志中看到的那样。
$ nomad agent -dev
No configuration files loaded
==> Starting Nomad agent...
==> Nomad agent configuration:
Client: true
Log Level: DEBUG
Region: global (DC: dc1)
Server: true
Version: 0.6.0
==> Nomad agent started! Log data will stream in below:
...
2017/08/18 15:45:28.373766 [DEBUG] client.consul: bootstrap contacting following Consul DCs: ["dc1"]
2017/08/18 15:45:28.377703 [INFO] client.consul: discovered following Servers: 127.0.0.1:4647
2017/08/18 15:45:28.378851 [INFO] client: node registration complete
2017/08/18 15:45:28.378895 [DEBUG] client: periodically checking for node changes at duration 5s
2017/08/18 15:45:28.379232 [DEBUG] consul.sync: registered 1 services, 1 checks; deregistered 0 services, 0 checks
...
然后我使用以下配置文件
运行redis作业
job "nomad-redis" {
datacenters = ["dc1"]
type = "service"
group "cache" {
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
port_map {
db = 6379
}
}
resources {
cpu = 500 # 500 MHz
memory = 256 # 256MB
network {
mbits = 10
port "db" {}
}
}
service {
name = "redis"
port = "db"
check {
name = "alive"
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
}
}
}
Redis服务被添加到领事馆,但它看起来很关键。似乎无法完成健康检查。据我所知,检查是在任务中完成的。有什么我想念的吗?
答案 0 :(得分:0)
在localhost或连接到主机网络的容器(--net = host)上运行Consul修复了这个问题。