【发布时间】:2023-02-17 05:42:32
【问题描述】:
我有以下基本的 nginx Nomad 工作:
job "hello" {
datacenters = ["aus01"]
group "hello" {
network {
port "http" {
to = 80 # <--- Notice the port 80 specified here
}
}
service {
name = "hello"
provider = "nomad"
port = "http"
tags = ["ingress"]
meta {
hostname = "ironforge.x17.space"
}
}
task "hello" {
driver = "docker"
config {
image = "nginx"
ports = ["http"]
}
}
}
}
在我的入口配置中,我映射到hello服务的动态地址和端口:
ingress:
{{- range nomadService "hello" }}
- service: http://{{ .Address }}:{{ .Port }}
hostname: ironforge.x17.space
{{- end }}
这呈现为:
ingress:
- service: http://192.168.86.36:28868
hostname: ironforge.x17.space
但是,我不明白为什么我需要在我的hello 组网络节中指定端口 80,以及为什么如果删除它,入口将停止工作。
to (string:nil)- 在使用“桥接”模式配置端口以映射到任务的网络命名空间内部时适用。省略此字段或将其设置为 -1 会将映射端口设置为等于调度程序分配的动态端口。 NOMAD_PORT_ 环境变量将包含 to 值。那么,如果映射端口设置为动态,为什么我的入口停止工作?毕竟,最终的入口配置甚至没有以任何方式引用 80 端口。
【问题讨论】:
标签: nomad