-
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
Default behavior for port mapping #6958
Comments
I'm doing some networking documentation cleanup and this issue seems to conflict with #9456 where they're claiming that we already have this. I've verified this with the following jobspec on Nomad 1.1.2: jobspecjob "example" {
datacenters = ["dc1"]
group "web" {
network {
mode = "bridge"
port "www" {
// to = 8001
}
}
task "httpd" {
driver = "docker"
config {
image = "busybox:1"
command = "httpd"
args = ["-v", "-f", "-p", "${NOMAD_PORT_www}", "-h", "/local"]
ports = ["www"]
}
template {
data = "<html>hello, world</html>"
destination = "local/index.html"
}
resources {
cpu = 128
memory = 128
}
}
}
} Run the job and see that the unspecified port is being mapped to the dynamic port, just as this issue says:
So it sounds like the way we could close out both #6958 and #9456 is to change the port map diff --git a/website/content/docs/job-specification/network.mdx b/website/content/docs/job-specification/network.mdx
index 02f688830..7d1a1ceb0 100644
--- a/website/content/docs/job-specification/network.mdx
+++ b/website/content/docs/job-specification/network.mdx
@@ -72,9 +72,10 @@ job "docs" {
dynamic port is chosen. We **do not recommend** using static ports, except
for `system` or specialized jobs like load balancers.
- `to` `(string:nil)` - Applicable when using "bridge" mode to configure port
- to map to inside the task's network namespace. `-1` sets the mapped port equal to the
- dynamic port allocated by the scheduler. The `NOMAD_PORT_<label>` environment variable
- will contain the `to` value.
+ to map to inside the task's network namespace. Omitting this field or
+ setting it to `-1` sets the mapped port equal to the dynamic port allocated
+ by the scheduler. The `NOMAD_PORT_<label>` environment variable will contain
+ the `to` value.
- `host_network` `(string:nil)` - Designates the host network name to use when allocating
the port. When port mapping the host port will only forward traffic to the matched host
network address. |
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. |
Currently the following network stanza will generate an error:
This is because there is no
to
field in the port stanza. We should change this to map theto
field to what ever the host port is assigned. This means for a dynamic port, ifto
is not specified Nomad will map the port to the same value that is allocated for the dynamic port. For static ports, this means the port will get mapped to the same port specified instatic
.This change should be noted in the Version Specific Upgrade notes as its a significant change in behavior.
The text was updated successfully, but these errors were encountered: