This repo contains files allowing to setup a Mesos Marathon cluster using Vagrant and Ansible. The main goals of this repo were to help me to understand how Vagrant and Ansible work together and teach me how the Mesos Marathon can be setup and for what purpose.
You will need to have the following softwares installed on your system:
- Vagrant
- Ansible
- A VM hypervisor like libvirt/KVM, Docker or Virtualbox
Using libvirt/KVM is strongly recommended as it is known to be lighter (less resource consuming) than the other supervisors.
The box used to build the machines is centos/7 which contains a CentOS operating system.
To launch the stack with 1 mesos-master (node1) and 3 mesos-slaves (node2, node3, node4):
- Download the outyet demo application
- Build the container by doing:
cd ~/go//src/github.com/golang/example/outyet
sudo docker build -t outyet .
- Go to the project's
my-cluster/vm-install
directory. sudo docker save --output=outyet.tar.gz outyet
so that the image will be saved in this directory.- Start the Mesos cluster by launching
vagrant up
in thevm-install
directory.
The stack takes a few minutes to start the first time because a lot of things need to be done (install zookeeper, mesos, marathon, chronos, ...). Next start up are faster once the VMs images are built.
Once the VMs have booted, you can try to access to Marathon UI at the
ip address http://192.168.33.10:8080
.
You can easily test Mesos Marathon by creating an application
from Marathon UI whose command is python -m SimpleHTTPServer $PORT0
.
This launches a HTTP server using python. You can also test the Marathon API by launching
curl -X POST http://192.168.33.10:8080/v2/apps -d @/vagrant/test.json -H "Content-type: application/json"
. You should then see the application
running. You can then scale up the application to see if mesos-dns works
and every instance gets its own access port and subdomain.
You can test if mesos-dns works by launching
curl http://192.168.33.10:8123/v1/hosts/test.marathon.mesos
.
If you want to check docker containers deployment works, you can try to
deploy the outyet application through Marathon UI by creating
an application whose command is sudo docker run --publish $PORT0:8080 --name test --rm outyet
.
Alternatively, you can use Marathon API and push the app with curl
by launching curl -X POST http://192.168.33.10:8080/v2/apps -d @/vagrant/outyet.json -H "Content-type: application/json"
.
If you experience problems intalling vagrant plugins and your distribution is Ubuntu 16.04, use this solution.