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

[feature-request] Allow specifying port ranges in network stanza #3242

Open
ryanmickler opened this issue Sep 18, 2017 · 12 comments
Open

[feature-request] Allow specifying port ranges in network stanza #3242

ryanmickler opened this issue Sep 18, 2017 · 12 comments
Labels

Comments

@ryanmickler
Copy link
Contributor

ryanmickler commented Sep 18, 2017

I have a 'system' job that starts couchbase server instances, using the official couchbase server container. This container needs a lot of ports open (e.g. 21100-21299) to share data when running in clustered mode. The only way we've been able to get this to work

               network {
                    #...
                    port	"nodeDataA"	{ static =  21100 }
                    port	"nodeDataB"	{ static =  21101 }
                    port	"nodeDataC"	{ static =  21102 }
                    #...
                    }

in the network block, and a similar thing in the port_map block. (you can imagine how huge the jobfile has become)

Is there another way to achieve this?

Can i suggest something like

                network {
                    # ...
                    port_block	"nodeData"	{ 
                        static_range_begin =  21100
                        static_range_end =  21299
                       }
                    # ...
                    }
@schmichael schmichael changed the title [question] [feature-request] Block port opening for jobs [feature-request] Allow specifying port ranges in network stanza Sep 25, 2017
@schmichael
Copy link
Member

Thanks for the good writeup and use case @ryanmickler! Seems like something Nomad should handle better.

@joshuaclausen
Copy link

2 use cases that being able to specify the dynamic port range in the network stanza would support:

  1. Legacy applications that have external dependencies on a specific port range, e.g. Xbox Live Services requires a defined port range for online services that an application on an Xbox will be permitted to call out to. That list may not be in the default Nomad port range.

  2. Applications (legacy ones especially) that need to restrict access to specific client IPs could specify a port range that falls within a predefined firewall rule on the nomad client host.

@shantanugadgil
Copy link
Contributor

I have recently solved this using a jinja template and a for loop within jinja to do something similar.
I also added the for loop for the service blocks.

FWIW, I changed the restart mode of the job to fail as all processes inside the job don't necessarily exist all the time.

@joshuaclausen
Copy link

I solved this by setting some meta tags in the jobspec that defined my desired port range, writing a "harness" script that picked a port from that range, making sure no other processes were listening on that port, and then running my executable on that port. I have no network resource stanza in the jobspec now, but that seems to be just fine as far as Nomad is concerned.

I can see how it may be wise to leave this sort of use case up to the user to solve.

@lmayorga1980
Copy link

I think this fits into my current scenario

Dockerfile

##
EXPOSE 5000-5200
##

Do I need to expose those 200 ports explicitly into the nomad job specification file? That is 200 extra lines.

@tgross tgross added this to Needs Roadmapping in Nomad - Community Issues Triage Feb 12, 2021
@tgross tgross removed this from Needs Roadmapping in Nomad - Community Issues Triage Mar 4, 2021
@sanjeevkumarraob
Copy link

This is a must support for nomad. When this will be implemented?

@kholisrag
Copy link

kholisrag commented Jan 18, 2022

I solved this by setting some meta tags in the jobspec that defined my desired port range, writing a "harness" script that picked a port from that range, making sure no other processes were listening on that port, and then running my executable on that port. I have no network resource stanza in the jobspec now, but that seems to be just fine as far as Nomad is concerned.

I can see how it may be wise to leave this sort of use case up to the user to solve.

Hi can you share from technical perspective, I need a port range scenario too, to solve my problems

@konsti
Copy link

konsti commented Jan 21, 2022

Another use case is WebRTC where typically a range of UDP ports need to be opened.

@mikenomitch mikenomitch added the help-wanted We encourage community PRs for these issues! label Aug 11, 2022
@ghost
Copy link

ghost commented Jan 14, 2023

Another use case is WebRTC where typically a range of UDP ports need to be opened.

exactly my issue, so having to drop nomad for now
back to k8s

@shantanugadgil
Copy link
Contributor

Another use case is WebRTC where typically a range of UDP ports need to be opened.

exactly my issue, so having to drop nomad for now back to k8s

🤕

Just thinking and a curiosity question: An external job file generator like Levant, Nomad's Terraform provider ❓ , some jinja based wrapper, etc. did not work?
(anything which has a loop construct)

I think one of the problems with block ranges would be how the port name would be referenced. As of today every port has an identifier.

@ryanmickler
Copy link
Contributor Author

Thanks @shantanugadgil, Indeed, I ended up using terraform to provision the nomad job file (and deploy the job), so that i could loop over the ports.

@ghost
Copy link

ghost commented Jan 16, 2023

Thanks @shantanugadgil, Indeed, I ended up using terraform to provision the nomad job file (and deploy the job), so that i could loop over the ports.

hmmm, yeah that would work. but I need to open up 10000 ports (yes, 10 thousand), for webrtc, 50-60k
might be a stretch 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants