-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support SO_REUSEPORT
for safe reuse of static ports
#15487
Comments
Hi @victorstewart! Unfortunately the docs aren't incorrect here, as the scheduler checks for port collisions. So if you run a job like the following: job with static portjob "httpd" {
datacenters = ["dc1"]
group "web" {
network {
mode = "host"
port "www" {
static = 8001
}
}
task "http" {
driver = "docker"
config {
image = "busybox:1"
command = "httpd"
args = ["-v", "-f", "-p", "8001", "-h", "/local"]
ports = ["www"]
}
template {
data = "<html>hello, world</html>"
destination = "local/index.html"
}
resources {
cpu = 128
memory = 128
}
}
}
} That'll run fine, and then if you run the same job with a different ID the scheduler will reject it:
The |
SO_REUSEPORT
for safe reuse of static ports
okay no worries. between now and then i ended up writing my own machine orchestrator, program scheduler and container runtime... just ended up being the path of least resistance for me for many reasons. so i ended up completely sidestepping this issue. but i do think this is an important feature. take an array of QUIC programs that use a load balancer to assist connection establishment, then switch to their unique unicast address. all of these servers must run on the public (read: external facing) 443 port for most client firewalls, at whatever waypoint, to reliably allow the UDP traffic through. but this pattern would be impossible in Nomad today. (not everyone load balances or proxies all traffic through CNI meshes). best of luck! |
In our infrastructure, because 443 is generally only used by HAProxy for load balancing, we opted to NOT register the port with Nomad at all but to still have the application listen on 443. We also created tags that other jobs (that might want to use 443) can use as a negative constraint to avoid scheduling on nodes with HAProxy. By doing the above, we can take advantage of |
edit: the below will be released in Nomad 1.9! Howdy folks! I have a draft PR #23956 up for this, and I'd love to hear any feedback about whether it would or would not improve the situation for any particular use cases. Lots of detail in the PR description, but in short: how would being able to specify a port, but ignore collisions, affect your deployments? group "g" {
network {
mode = "host"
port "http" {
static = 8000
to = 8000
ignore_collision = true
}
}
task "t" {
... |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
on https://developer.hashicorp.com/nomad/docs/job-specification/network#host_network
it states...
but this is false: if using host networking, and SO_REUSEPORT, ports can be shared. docker supports this, i assume the containerd plugin as well.
just wanted to confirm Nomad doesn't refuse to start jobs that all use the same static port.
The text was updated successfully, but these errors were encountered: