From 9c602da75559a4cf65b0b46e05a05503c20f3d71 Mon Sep 17 00:00:00 2001 From: Sukhesh Halemane Date: Fri, 25 Mar 2016 18:20:43 -0700 Subject: [PATCH 1/3] vagrant setup for mesos,marathon,docker and netplugin --- mgmtfn/mesos-docker/README.md | 85 +++++++++++++++ mgmtfn/mesos-docker/Vagrantfile | 169 +++++++++++++++++++++++++++++ mgmtfn/mesos-docker/docker.json | 18 +++ mgmtfn/mesos-docker/launch.sh | 12 ++ mgmtfn/mesos-docker/playbook.yml | 54 +++++++++ mgmtfn/mesos-docker/startPlugin.sh | 7 ++ 6 files changed, 345 insertions(+) create mode 100644 mgmtfn/mesos-docker/README.md create mode 100644 mgmtfn/mesos-docker/Vagrantfile create mode 100644 mgmtfn/mesos-docker/docker.json create mode 100755 mgmtfn/mesos-docker/launch.sh create mode 100644 mgmtfn/mesos-docker/playbook.yml create mode 100755 mgmtfn/mesos-docker/startPlugin.sh diff --git a/mgmtfn/mesos-docker/README.md b/mgmtfn/mesos-docker/README.md new file mode 100644 index 000000000..652ed14fb --- /dev/null +++ b/mgmtfn/mesos-docker/README.md @@ -0,0 +1,85 @@ +# Netplugin with Mesos Marathon + +This document explains how to use Netplugin with Mesos Marathon. Currently, netplugin supports docker containerizer with Mesos Marathon. + +## Getting started with Vagrant VMs +### Prerequisits +- Virtualbox 5.0.2 or higher +- Vagrant 1.7.4 or higher +- ansible 1.9.4 or higher + +### Step 1: Bring up the vagrant VMs + +``` +$ git clone https://github.com/contiv/netplugin +$ cd netplugin/mgmtfn/mesos-docker +$ vagrant up +``` + +This will bring up a two node Vagrant setup with Mesos, Marathon and docker. +Bringing up vagrant VMs and provisioning them can take few minutes to complete since it needs to download the VM images and mesos/marathon binaries. Please be patient. + +### Step 2: Build netplugin binaries + +``` +$ vagrant ssh node1 +< Inside the VM> +$ cd /opt/gopath/src/github.com/contiv/netplugin +$ make host-build +``` + +### Step 3: Start netplugin + +``` +$ cd mgmtfn/mesos-docker +$ ./startPlugin.sh +``` + +This will start netplugin and netmaster processes on both VMs in the setup. +This will also create a network called `contiv` to launch marathon containers + +### Step 4: Launch containers + +`docker.json` file in mgmtfn/mesos-docker directory has an example marathon app definition. + +``` + + "container": { + "type": "DOCKER", + "docker": { + "image": "libmesos/ubuntu", + "parameters": [ { "key": "net", "value": "contiv" } ] + } + }, + "id": "ubuntu", + "instances": 2, + "constraints": [ ["hostname", "UNIQUE", ""] ], + "cpus": 1, + "mem": 128, + "uris": [], + "cmd": "while sleep 10; do date -u +%T; done" +} +``` + +This example application definition launches two ubuntu containers with a constraint that both containers be spread on different hosts. +Note that there is a special `net` parameter used in this specification `"parameters": [ { "key": "net", "value": "contiv" } ]`. This tells docker to launch the application in contiv network that we created in step 3. + +You can launch this application using following command + +``` +$ ./launch.sh docker.json +``` + +Launching the container can take few minutes depending on how long it takes to pull the image. +Once its launched, you should be able to see the containers using docker commands + +``` +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +2a68fed77d5a libmesos/ubuntu "/bin/sh -c 'while sl" About an hour ago Up About an hour mesos-cce1c91f-65fb-457d-99af-5fdd4af14f16-S1.da634e3c-1fde-479a-b100-c61a498bcbe7 + ``` + +## Notes + + 1. Mesos and Marathon ports are port-mapped from vagrant VM to host machine. You can access them by logging into localhost:5050 and localhost:8080 respectively. + 2. Netmaster web-ui is port-mapped to port 9090 on the host machine diff --git a/mgmtfn/mesos-docker/Vagrantfile b/mgmtfn/mesos-docker/Vagrantfile new file mode 100644 index 000000000..7bb0b501b --- /dev/null +++ b/mgmtfn/mesos-docker/Vagrantfile @@ -0,0 +1,169 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +require 'fileutils' + +# netplugin_synced_gopath="/opt/golang" +gopath_folder="/opt/gopath" + +ANSIBLE_GROUPS = { + "master" => ["node1"], + "nodes" => ["node2"], + "all_groups:children" => ["master, ""nodes"] + } + +provision_common = <