0
votes

I want a set of apps to use a specific range of ports and the rest of the apps to use another range

On mesos-agent I've set: --resources="ports(*):[8000-9000, 31000-32000]"

I want to spawn 100 × APP1 and use BRIDGE network with hostPorts in portbindings from range 8000-9000 and the rest of apps (APP2,APP3,...APPN) to use range 31000-32000.

Is it possible?

Right now APP2,3 ... APPN can take ports from range 8000-9000, which for me is not desirable.

UPDATE: I created a role for the resource port range 8000-9000 (static reservation). Checked in the mesos-master:5050/slaves and it seems to be ok

"reserved_resources": {
    "app1": {
        "disk": 0.0,
        "mem": 0.0,
        "gpus": 0.0,
        "cpus": 0.0,
        "ports": "[8000-9000]"
    }
}

and

    "reserved_resources_full": {
        "app1": [{
            "name": "ports",
            "type": "RANGES",
            "ranges": {
                "range": [{
                    "begin": 8000,
                    "end": 9000
                }]
            },
            "role": "app1",
            "reservations": [{
                "type": "STATIC",
                "role": "app1"
            }]
        }]
    }

it was also assigning zero to disk, mem etc. don't know why it's acting like this. In marathon I've added:

"acceptedResourceRoles": [
    "app1"
]

But it didn't deploy the app. I've put marathon logging into trace:

Considering resources with roles {app1} without resident reservation labels. Not all basic resources satisfied: cpus NOT SATISFIED (0.1 > 0.0), mem NOT SATISFIED (512.0 > 0.0) (mesosphere.mesos.ResourceMatcher$:marathon-akka.actor.default-dispatcher-33)

I then modified:

"acceptedResourceRoles": [
   "app1",
   "*"
]

And now it says:

Considering resources with roles {app1, *} without resident reservation labels. Cannot find range with host port 8111 for run spec

There is nothing in the docs regarding resident reservation labels. There is reservation labels but it doesn't say how to create or add a label or just a small example. For roles there is something linked to ACLs but very fuzzy and it seems to get into users and permissions, not what resourse reservation is about.

1

1 Answers

0
votes

So I found a way to make it work. I don't know if it's the correct way to do it but I don't have anything else to compare it with so here it goes:

  1. On the masters I appended in /etc/default/mesos-master

    MESOS_ROLES="*,app1"
    
  2. On mesos slaves I appended in /etc/default/mesos-slave

    MESOS_RESOURCES="ports(*):[30000-32000];cpus(*):4.0;mem(*):15023.0;disk(*):34522.0;ports(app1):[8000-9000]"
    MESOS_ROLES="app1"
    

and removed the --resources parameter from the exec script

  1. On the marathon masters I appended in /etc/default/marathon

    MARATHON_MESOS_ROLE="app1"
    

Restart all mesos masters and slaves and all the apps with resource roles "app1" are spawining with their ports in my desired range [8000-9000].