How to define two static port

485 views
Skip to first unread message

Parveen Kumar

unread,
Apr 3, 2016, 11:55:17 PM4/3/16
to Nomad
Hi all,

I need to create  a job to deploy an application which listens on 2 ports. 1 is 8080(http) and another is 8086(websocket).
i am using docker as driver and under config giving the image address.
when i write

        port_map {
          HTTP = [8088,8086]
        }

        # Request for a static port
          port "HTTP" {
            static = [8080,8086]
          }
the nomad job is failing.
Error parsing job file melody-all.sh: error parsing 'job': group: 'ms', task: 'gc', resources, network, ports -> 1 error(s) decoding:

* 'static' expected type 'int', got unconvertible type '[]interface {}'

please suggest other way around.

Parveen Kumar

unread,
Apr 5, 2016, 4:26:36 AM4/5/16
to Nomad
Can we define two static ports for a single task?? if yes, how??

Diptanu Choudhury

unread,
Apr 5, 2016, 3:14:58 PM4/5/16
to Parveen Kumar, Nomad
Hi Parveen,

You can add multiple "port" blocks in the resources section of a Task in the job config.

For example -

port "http" {
}
port "admin" {
  static = "8086"
}
port "debug" {
  static = "3056"
}

That would request the scheduler to reserve one dynamic port and two static ports.

On Tue, Apr 5, 2016 at 1:26 AM, Parveen Kumar <parveenk...@gmail.com> wrote:
Can we define two static ports for a single task?? if yes, how??

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/nomad/issues
IRC: #nomad-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Nomad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nomad-tool+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nomad-tool/32b1c3be-3804-4643-92a0-fcd75ded5c1f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks,
Diptanu Choudhury

Parveen Kumar

unread,
Apr 5, 2016, 11:55:33 PM4/5/16
to Nomad
Hi Diptanu,

It worked. i was just trying to assign each port in a single port block and somehow forgot the nomad capability. Thanks.

Thanks,
Parveen Kumar
Reply all
Reply to author
Forward
0 new messages