Configuring resource offers on Mesos


by Frank Scholten

Apache Mesos

The other day I was working on Mesos Elasticsearch and encountered a problem while running the framework. The framework did not accept any offers from slaves because I had not properly configured the resources. Right now the Elasticsearch framework requires ports 9200 and 9300 but by default the slaves offer a port range 31000 to 32000. The default slave resources offers are defined in src/slave/constants.cpp. See the snippet below.

const double DEFAULT_CPUS = 1;
const Bytes DEFAULT_MEM = Gigabytes(1);
const Bytes DEFAULT_DISK = Gigabytes(10);
const std::string DEFAULT_PORTS = "[31000-32000]";

There are two ways to configure the slaves to offer the correct resources. The first is to add a resources parameter to the mesos-slave command like this:

$ /usr/local/sbin/mesos-slave --resources='ports:[9200-9200,9300-9300]' ...

The resource string is a comma-separated string consisting of scalar, ranges and sets. Checkout the Mesos resources documentation to see how to create valid resources expressions. The other way to configure resources is to create a file under /etc/mesos-slave called resources whose contents is the resource string.

$ cat /etc/mesos-slave/resources

Note that any type of configuration can be expressed this way. This is really useful when provisioning a cluster. For instance with Terraform. For more information about configuration checkout the Mesos configuration documentation.

The following two tabs change content below.

Frank Scholten

Senior Software Engineer at Container Solutions
Frank is a senior software engineer at Container Solutions. He focuses on Cloud Native applications with DC/OS and Apache Mesos, containers and Continuous Delivery. He created minimesos, the experimentation and testing tool for Apache Mesos. He is enthusiastic about Open Source software development, process improvement and automation in particular. Drawing on experience from a wide range of projects he is always on the lookout for new technologies, methods and ways to improve things and likes to write on speak on these topics.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *