- To use marathon constraints, we can specify attributes to every mesos node.
- Attributes are defined in key:value pairs and node can have multiple attributes.
- Attributes are useful to categorize the node, for example: nodes for DB servers can have attribute like 'SERVER_TYPE:DB' or 'DB_TYPE:MYSQL'
- Attributes are useful to add constraints on marathon apps to run on run on nodes with specific attributes.
-
SSH on node
-
Create or edit file
sudo vi /var/lib/dcos/mesos-slave-common
-
Add contents as :
MESOS_ATTRIBUTES=<key1>:<value1>;<key2>:<value2>;...;<keyN>:<valueN>
Note - multiple attributes are separated by semicolon [;].
Example: MESOS_ATTRIBUTES=TYPE:DB;DB_TYPE:MONGO; -
Stop dcos-mesos-slave service
sudo systemctl stop dcos-mesos-slave
-
Remove link for latest slave metadata
sudo rm -f /var/lib/mesos/slave/meta/slaves/latest
-
Start dcos-mesos-slave service
sudo systemctl start dcos-mesos-slave
-
Check status of dcos-mesos-slave service
sudo systemctl status dcos-mesos-slave
-
Wait for some time, node will be in HEALTHY state again.
-
Add app placement constraint with field = key and value = value
-
Verify attributes, run on any node
curl -s http://leader.mesos:5050/state | jq '.slaves[]| .hostname ,.attributes'
or Check DCOS UI Nodes => Select any Node => Details Tab