Skip to content

Instantly share code, notes, and snippets.

@sttts
Created January 10, 2015 22:12
Show Gist options
  • Save sttts/ccde0f55fc90ecf435eb to your computer and use it in GitHub Desktop.
Save sttts/ccde0f55fc90ecf435eb to your computer and use it in GitHub Desktop.
Marathon json generator for 3 mongos
var _ = require("underscore/underscore.js");
replicas=3;
seedlist=_.range(replicas)
.map(function(r) {return r+1})
.map(function(r) {return "r" + r + ".tweventy.mongo.service.dc1.consul"})
.join()
console.log(JSON.stringify({
"id": "/mongo",
"groups": [{
"id": "tweventy",
"apps": _.range(replicas).map(function(r) {return r+1}).map(function(r) { return {
"id": "r" + r,
"container": {
"type": "DOCKER",
"docker": {
"image": "mongo:2.8.0",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 27017, "hostPort": "27017", "protocol": "tcp"}
]
},
"volumes": [{
"containerPath": "/data/db",
"hostPath": "/local/tweventy/mongo/r" + r,
"mode": "RW"
},
{
"containerPath": "/etc/mongodb-keyfile.orig",
"hostPath": "/cluster/tweventy/mongodb-keyfile",
"mode": "RO"
}]
},
"cmd": [
"cp /etc/mongodb-keyfile.orig /etc/mongodb-keyfile",
"chown mongodb /etc/mongodb-keyfile",
"chmod 600 /etc/mongodb-keyfile",
"/entrypoint.sh " +
[
"--replSet", "rs1" /* + (r == 1 ? "/" + seedlist : "")*/,
"--keyFile", "/etc/mongodb-keyfile",
"--directoryperdb"
].join(" ")
].join("; "),
"env": { "SERVICE_TAGS": "r" + r + ".tweventy" },
"cpus": 1,
"mem": 512,
"instances": 1,
"healthChecks": [{
"protocol": "TCP"
}],
"upgradeStrategy": {
"minimumHealthCapacity": 0.0
},
"constraints": [["hostname", "CLUSTER", "master" + r]]
}})
}]
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment