Created
June 23, 2018 08:05
-
-
Save pkazi/61c4b1d70e4e3050e6d251382ce3b4b0 to your computer and use it in GitHub Desktop.
Add node attributes to dcos nodes and run apps on nodes with required attributes using placement constraints.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#1. SSH on node | |
#2. Create or edit file /var/lib/dcos/mesos-slave-common | |
#3. Add contents as : | |
# MESOS_ATTRIBUTES=<key>:<value> | |
# Example: | |
# MESOS_ATTRIBUTES=TYPE:DB;DB_TYPE:MONGO; | |
#4. Stop dcos-mesos-slave service | |
# systemctl stop dcos-mesos-slave | |
#5. Remove link for latest slave metadata | |
# rm -f /var/lib/mesos/slave/meta/slaves/latest | |
#6. Start dcos-mesos-slave service | |
# systemctl start dcos-mesos-slave | |
#7. Wait for some time, node will be in HEALTHY state again. | |
#8. Add app placement constraint with field = key and value = value | |
#9. Verify attributes, run on any node | |
# curl -s http://leader.mesos:5050/state | jq '.slaves[]| .hostname ,.attributes' | |
# OR Check DCOS cluster UI | |
# Nodes => Select any Node => Details Tab | |
tmpScript=$(mktemp "/tmp/addDcosNodeAttributes-XXXXXXXX") | |
# key:value paired attribues, separated by ; | |
ATTRIBUTES=NODE_TYPE:GPU_NODE | |
cat <<EOF > ${tmpScript} | |
echo "MESOS_ATTRIBUTES=${ATTRIBUTES}" | sudo tee /var/lib/dcos/mesos-slave-common | |
sudo systemctl stop dcos-mesos-slave | |
sudo rm -f /var/lib/mesos/slave/meta/slaves/latest | |
sudo systemctl start dcos-mesos-slave | |
EOF | |
# Add the private ip of nodes on which you want to add attrubutes, one ip per line. | |
for i in `cat nodes.txt`; do | |
echo $i | |
dcos node ssh --master-proxy --option StrictHostKeyChecking=no --private-ip $i <$tmpScript | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment