Mesos-DNS installation and configuration

Context: I followed these steps to install Mesos DNS and launch it on Marathon.

1. Install golang

# wget
# 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

4. Install mesos-dns dependencies

# go get
# go get
# go get

5. Install Mesos-DNS itself
We get the code from github, build it, and get the binary that’s generated:

# git clone
# 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:
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": ["",""],
"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:

.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):

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


Loved this article? Send Ethereum to this address: 0x9b09d5b83395FE4F43e4746a8c44E8d8491799A3

Mesos-DNS installation and configuration