Skip to content
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

Port selection in alloc network mode #9730

Closed
nickethier opened this issue Jan 5, 2021 · 1 comment · Fixed by #9739
Closed

Port selection in alloc network mode #9730

nickethier opened this issue Jan 5, 2021 · 1 comment · Fixed by #9739

Comments

@nickethier
Copy link
Member

When using the alloc network mode in a service stanza, Nomad will register the service with the allocation's IP address and the port of the given label. However, it is often the case when using this feature that the to value of the referenced port is desired to be used. You can override the service port field with a numeric value, but this will also change the port any defined checks use.

Take the following example of a legacy service which identifies itself by its IP address and a layer 3 network configured by CNI. The service requires each instance to have a unique IP address. Rather than use a distinct_host constraint you'd like to configure each allocation with a seperate IP (out of scope of the issue).

group {
  network {
    mode = "cni/mynet"
    port "listener" {
      to = 9999
    }

  service {
    name = "legacy"
    port = "listener"
    addr_mode = "alloc"
    check {
      type = "tcp"
    }
  }
}

In this example you'd like the service to be registered in consul with allocIP:9999, the address and port the application is bound on. Currently the actual result is a registration with the dynamic port. The check comes from the client and may not be able to route to the allocation address. Therefore the check doesn't inherit the addr_mode from the service and will use the host addr_mode which uses hostIP:dynamicPort as the check target which is port mapped to the alloc's address.

The proposal is to change the registration for alloc addr_mode to use the to value of the port label and fall back to the dynamic/static value if not set.

@github-actions
Copy link

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant