Context: I followed these steps to install Mesos DNS and launch it on Marathon.
1. Install golang
# wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz # tar -C /usr/local -xvzf go1.4.2.linux-amd64.tar.gz
2. Set up golang environment variables
Add this line:
export PATH=$PATH:/usr/local/go/bin
at the end of /etc/profile file. You can then run
# source /etc/profile
to apply your changes without reloading the terminal.
3. Install godep
We set some environment variables for the godep installation (no need to edit /etc/profile this time, the command line is enough):
# export GOPATH=$HOME/go # export PATH=$PATH:$GOPATH/bin
and install godep:
# go get github.com/tools/godep
4. Install mesos-dns dependencies
# go get github.com/mesosphere/mesos-dns/logging # go get github.com/mesosphere/mesos-dns/records # go get github.com/mesosphere/mesos-dns/resolver
5. Install Mesos-DNS itself
We get the code from github, build it, and get the binary that’s generated:
# git clone https://github.com/mesosphere/mesos-dns.git # cd mesos-dns # make build # mv mesos-dns /usr/local/bin/
6. Configure Mesos-DNS
# mkdir /etc/mesos-dns # cp config.json.sample /etc/mesos-dns/config.json # cd /etc/mesos-dns/
And edit the file config.json
See the documentation concerning the different options: http://mesosphere.github.io/mesos-dns/docs/configuration-parameters.html
In my case /etc/mesos-dns/config.json looks like this (replace text in ):
{
"zk": "zk://:2181/mesos",
"masters": [":5050"],
"refreshSeconds": 60,
"ttl": 60,
"domain": "mesos",
"resolvers": ["","8.8.8.8"],
"listener": "",
"email": "root.mesos-dns.mesos"
}
Note: In my case, when running mesos-dns on master, the master doesn’t like the IP provided by Zookeeper (even if it’s a valid one) so I removed the first line of the configuration (“zk”:….)
7. Little test to check it’s working
Run mesos-dns:
# mesos-dns -config=/etc/mesos-dns/config.json &
And check the name resolution:
$ dig .marathon.mesos @
You should see a line like:
;; ANSWER SECTION: .marathon.mesos. 60 IN A
Your applications running on mesos will be accessible at ..mesos (in our example above the framework is Marathon)
8. Set Mesos-DNS as our official DNS resolver
To run on all hosts that will need to resolve those names:
# sed -i '1s/^/nameserver \n /' /etc/resolv.conf
Note: other solution (instead of sed): http://askubuntu.com/questions/157154/how-do-i-include-lines-in-resolv-conf-that-wont-get-lost-on-reboot
9. Run Mesos DNS on Marathon
You can kill the Mesos DNS process we launched for testing at step 7.
Create a file that will contain the Marathon configuration for Mesos DNS (in my case /tmp/MesosDNS.json):
{
"cmd": "sudo /usr/local/bin/mesos-dns -config=/etc/mesos-dns/config.json",
"cpus": 1.0,
"mem": 512,
"id": "mesos-dns",
"instances": 1,
"constraints": [["hostname", "CLUSTER", ""]]
}
The constraint on the hostname (last line) is optional. In my case I force mesos-dns to run on a specific slave.
And launch:
curl -X POST -H 'Content-Type: application/json' http://:8080/v2/apps -d@/tmp/MesosDNS.json
References
http://mesosphere.github.io/mesos-dns/docs/
Loved this article? Send Ethereum to this address: 0x9b09d5b83395FE4F43e4746a8c44E8d8491799A3




