How to assign a task a port range? Is this possible?

I have a task (system job) running in nomad that is responsible for spinning up ephemeral subprocesses, which are short-lived and expose a websocket port as an event/data stream.

The subprocess picks an available port, and advertises it as the port a client can use to monitor it. Unfortunately the mechanism does not seem to work when running it within nomad. I can assign it a port range to draw from, but I cannot find a way to tell nomad that a task has a port range, rather than a set of statically defined ports, so when the process spins up it fails to find an available port.

Is this possible within nomad? Or is there some other mechanism I need to use? Or a custom driver or something?


1 Like

Did you solve this?

From the doc it seems not possible.

There’s an open issue to support port ranges in [feature-request] Allow specifying port ranges in network stanza · Issue #3242 · hashicorp/nomad · GitHub