Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 66 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Spin up your [Mesos](http://mesos.apache.org) cluster with [Vagrant](http://www.vagrantup.com)! (Both Virtualbox and AWS are supported.)

This spins up Mesos 0.22.1 cluster and also spins up a framework server node in which [Marathon](https://github.com/mesosphere/marathon) (0.8.2) and [Chronos](http://github.com/mesos/chronos) (2.1.0) are running. This means you can build your own __Mesos+Marathon+Chronos+Docker__ PaaS with `vagrant up`!! Marathon works as distributed `init.d` and Chronos works as distributed `cron`!! _If you wanted to deploy docker containers, please refer to the chapter "Deploy Docker Container with Marathon" in [this blog entry](http://frankhinek.com/deploy-docker-containers-on-mesos-0-20/)._
This spins up Mesos 0.28.0 cluster and also spins up a framework server node in which [Marathon](https://github.com/mesosphere/marathon) ( 0.15.3) and [Chronos](http://github.com/mesos/chronos) are running. This means you can build your own __Mesos+Marathon+Chronos+Docker__ PaaS with `vagrant up`!! Marathon works as distributed `init.d` and Chronos works as distributed `cron`!! _If you wanted to deploy docker containers, please refer to the chapter "Deploy Docker Container with Marathon" in [this blog entry](http://frankhinek.com/deploy-docker-containers-on-mesos-0-20/)._

* Using VirtualBox
* [Mesos Standalone on VirtualBox](#svb)
Expand Down Expand Up @@ -32,65 +32,6 @@ Prerequisites
* [vagrant-aws](https://github.com/mitchellh/vagrant-aws) (only if you use ec2.)
`$ vagrant plugin install vagrant-aws`

<a name="svb"></a>
Mesos Standalone on VirtualBox
----
It's so simple!

$ git clone https://github.com/everpeace/vagrant-mesos.git
$ cd vagrant-mesos/standalone
$ vagrant up

After box is up, you can see services running at:

* Mesos web UI on: <http://192.168.33.10:5050>
* [Marathon](https://github.com/mesosphere/marathon) web UI on: <http://192.168.33.10:8080>
* [Chronos](https://github.com/mesos/chronos) web UI on: <http://192.168.33.10:8081>

<a name="sec2"></a>
Mesos Standalone on EC2
----
1. Set ec2 credentials and some configurations defined in `standalone/aws_config.yml`. You have to fill up `EDIT_HERE` parts. Security group you'll set must accept at least tcp port 22(SSH) and 5050(mesos-master web ui) from outside of ec2.

# Please set AWS credentials
access_key_id: EDIT_HERE
secret_access_key: EDIT_HERE

# Please choose one from
# ["ap-northeast-1", "ap-southeast-1", "eu-west-1", "sa-east-1", "us-east-1",
# "us-west-1", "ap-southeast-2", "us-west-2"]
region: us-east-1

# array of security groups. e.g. ['sg*** ']
security_groups: EDIT_HERE

# See http://aws.amazon.com/ec2/instance-types/#selecting-instance-types
# for other instance types and its specs.
instance_type: m1.small

keypair_name: EDIT_HERE

ssh_private_key_path: EDIT_HERE

2. You can spin up mesos box on ec2 by the same way with the case of virtual box

cd standalone
vagrant up --provider=aws

After box is up, you can see services running at:

* Mesos web UI on: `http://#_public_dns_of_the_VM_#:5050`
* [Marathon](https://github.com/mesosphere/marathon) web UI on: `http://#_public_dns_of_the_VM_#:8080`
* [Chronos](https://github.com/mesos/chronos) web UI on: `http://#_public_dns_of_the_VM_#:8081`


_Tips: you can get public dns of the vm by:_

```
$ vagrant ssh -- 'echo http://`curl --silent http://169.254.169.254/latest/meta-data/public-hostname`:5050'
http://ec2-54-193-24-154.us-west-1.compute.amazonaws.com:5050
```

<a name="clvb"></a>
Mesos Cluster on VirtualBox
----
Expand All @@ -104,7 +45,7 @@ mesos_version: 0.22.1
# The numbers of servers
##############################
zk_n: 1 # hostname will be zk1, zk2, …
master_n: 1 # hostname will be master1,master2,…
master_n: 1 # hostname will be master1,master2,… (runs marathon and chronos also)
slave_n : 1 # hostname will be slave1,slave2,…

# Memory and Cpus setting(only for virtualbox)
Expand Down Expand Up @@ -136,8 +77,8 @@ $ vagrant up
At default setting, after all the boxes are up, you can see services running at:

* Mesos web UI on: <http://172.31.1.11:5050>
* [Marathon](https://github.com/mesosphere/marathon) web UI on: <http://172.31.3.11:8080>
* [Chronos](https://github.com/mesos/chronos) web UI on: <http://172.31.3.11:8081>
* [Marathon](https://github.com/mesosphere/marathon) web UI on: <http://172.31.1.11:8080>
* [Chronos](https://github.com/mesos/chronos) web UI on: <http://172.31.1.11:8081>

#### Destroy Cluster
this operations all VM instances forming the cluster.
Expand Down Expand Up @@ -250,3 +191,65 @@ This operations terminates all VMs instances forming the cluster.
$ cd multinodes
$ vagrant destroy
```



<a name="svb"></a>
Mesos Standalone on VirtualBox
----
It's so simple!

$ git clone https://github.com/everpeace/vagrant-mesos.git
$ cd vagrant-mesos/standalone
$ vagrant up

After box is up, you can see services running at:

* Mesos web UI on: <http://192.168.33.10:5050>
* [Marathon](https://github.com/mesosphere/marathon) web UI on: <http://192.168.33.10:8080>
* [Chronos](https://github.com/mesos/chronos) web UI on: <http://192.168.33.10:8081>

<a name="sec2"></a>
Mesos Standalone on EC2
----
1. Set ec2 credentials and some configurations defined in `standalone/aws_config.yml`. You have to fill up `EDIT_HERE` parts. Security group you'll set must accept at least tcp port 22(SSH) and 5050(mesos-master web ui) from outside of ec2.

# Please set AWS credentials
access_key_id: EDIT_HERE
secret_access_key: EDIT_HERE

# Please choose one from
# ["ap-northeast-1", "ap-southeast-1", "eu-west-1", "sa-east-1", "us-east-1",
# "us-west-1", "ap-southeast-2", "us-west-2"]
region: us-east-1

# array of security groups. e.g. ['sg*** ']
security_groups: EDIT_HERE

# See http://aws.amazon.com/ec2/instance-types/#selecting-instance-types
# for other instance types and its specs.
instance_type: m1.small

keypair_name: EDIT_HERE

ssh_private_key_path: EDIT_HERE

2. You can spin up mesos box on ec2 by the same way with the case of virtual box

cd standalone
vagrant up --provider=aws

After box is up, you can see services running at:

* Mesos web UI on: `http://#_public_dns_of_the_VM_#:5050`
* [Marathon](https://github.com/mesosphere/marathon) web UI on: `http://#_public_dns_of_the_VM_#:8080`
* [Chronos](https://github.com/mesos/chronos) web UI on: `http://#_public_dns_of_the_VM_#:8081`


_Tips: you can get public dns of the vm by:_

```
$ vagrant ssh -- 'echo http://`curl --silent http://169.254.169.254/latest/meta-data/public-hostname`:5050'
http://ec2-54-193-24-154.us-west-1.compute.amazonaws.com:5050
```

1 change: 1 addition & 0 deletions multinodes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.dockercfg
129 changes: 34 additions & 95 deletions multinodes/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,24 @@ Vagrant.configure("2") do |config|
cfg.vm.provision :shell, :inline => "mkdir -p #{master_work_dir}"
end



cfg.vm.provision :chef_solo do |chef|
# chef.log_level = :debug
chef.add_recipe "apt"

if master?(ninfo[:hostname]) then

#install marathon on masters
cfg.vm.provision "shell", path: "install-marathon.sh"

chef.add_recipe "mesos::master"
chef.json = {
:mesos=> {

:mesosphere => {
build_version: conf["mesos_build_version"]
},
:type => "mesosphere",
:version => conf["mesos_version"],
:master_ips => ninfos[:master].map { |m| "#{m[:ip]}" },
Expand All @@ -151,10 +161,15 @@ Vagrant.configure("2") do |config|
end
}
}

elsif slave?(ninfo[:hostname]) then
chef.add_recipe "mesos::slave"

chef.json = {
:mesos => {
:mesosphere => {
build_version: conf["mesos_build_version"]
},
:type => "mesosphere",
:version => conf["mesos_version"],
:slave => {
Expand All @@ -166,13 +181,25 @@ Vagrant.configure("2") do |config|
:ip => "#{ninfo[:ip]}",
:containerizers => "docker,mesos",
:isolation => "cgroups/cpu,cgroups/mem",
:hostname => "#{ninfo[:ip]}",
:executor_registration_timeout => "5mins",
:resources => "ports:[31000-32000,4040-4040,5432-5433,6000-7001,7080,7081,7199-7199,8012,8983,9042-9042,9160-9160,27000-29000,61621-61621]",
}
}
}

end
end

cfg.vm.provision :shell, :inline => <<-SCRIPT
echo """172.31.1.11 master1
172.31.1.12 master2
172.31.2.11 slave1
172.31.2.12 slave2
172.31.2.13 slave3
172.31.2.14 slave4""" | sudo tee -a /etc/hosts
SCRIPT

if zk?(ninfo[:hostname]) then
myid = (/zk([0-9]+)/.match ninfo[:hostname])[1]
cfg.vm.provision :shell, :inline => <<-SCRIPT
Expand All @@ -187,103 +214,15 @@ Vagrant.configure("2") do |config|

# If you wanted use `.dockercfg` file
# Please place the file simply on this directory
if File.exist?(".dockercfg")
config.vm.provision :shell, :priviledged => true, :inline => <<-SCRIPT
cp /vagrant/.dockercfg /root/.dockercfg
chmod 600 /root/.dockercfg
chown root /root/.dockercfg
SCRIPT
end
# if File.exist?(".dockercfg")
# config.vm.provision :shell, :priviledged => true, :inline => <<-SCRIPT
# cp /vagrant/.dockercfg /root/.dockercfg
# chmod 600 /root/.dockercfg
# chown root /root/.dockercfg
# SCRIPT
# end
end
end

if conf["marathon_enable"] then
config.vm.define :marathon do |cfg|
marathon_ip = conf["marathon_ipbase"]+"11"
cfg.vm.provider :virtualbox do |vb, override|
override.vm.hostname = "marathon"
override.vm.network :private_network, :ip => marathon_ip
override.vm.provision :hosts

vb.name = 'vagrant-mesos-' + "marathon"
vb.customize ["modifyvm", :id, "--memory", conf["marathon_mem"], "--cpus", conf["marathon_cpus"] ]

override.vm.provision :shell do |s|
s.path = "scripts/populate_sshkey.sh"
s.args = "/root root"
end

override.vm.provision :shell do |s|
s.path = "scripts/populate_sshkey.sh"
s.args = "/home/vagrant vagrant"
end
end
cfg.vm.provider :aws do |aws, override|
aws.access_key_id = conf["access_key_id"]
aws.secret_access_key = conf["secret_access_key"]

aws.region = conf["region"]
if conf["custom_ami"] then
override.vm.box = "dummy"
override.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
aws.ami = conf["custom_ami"]
end

# workaround for https://github.com/mitchellh/vagrant-aws/issues/275
aws.ami=""

aws.instance_type = conf["marathon_instance_type"]
aws.keypair_name = conf["keypair_name"]
aws.subnet_id = conf["subnet_id"]
aws.security_groups = conf["security_groups"]
aws.private_ip_address = marathon_ip
aws.tags = {
Name: "vagrant-mesos-marathon"
}
if !conf["default_vpc"] then
aws.associate_public_ip = true
end

override.ssh.username = "ubuntu"
override.ssh.private_key_path = conf["ssh_private_key_path"]

override.vm.provision :shell do |s|
s.path = "scripts/populate_sshkey.sh"
s.args = "/home/ubuntu ubuntu"
end

override.vm.provision :shell , :inline => <<-SCRIPT
PUBLIC_DNS=`wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname`
hostname $PUBLIC_DNS
echo $PUBLIC_DNS > /etc/hostname
HOSTNAME=$PUBLIC_DNS # Fix the bash built-in hostname variable too
SCRIPT
end

cfg.vm.provision :shell, :privileged => true, :inline => <<-SCRIPT
mkdir -p /var/log/marathon
kill -KILL `ps augwx | grep marathon | tr -s " " | cut -d' ' -f2`
LIBPROCESS_IP=#{marathon_ip} nohup /opt/marathon/bin/start --master #{"zk://"+ninfos[:zk].map{|zk| zk[:ip]+":2181"}.join(",")+"/mesos"} --zk_hosts #{ninfos[:zk].map{|zk| zk[:ip]+":2181"}.join(",")} --event_subscriber http_callback > /var/log/marathon/nohup.log 2> /var/log/marathon/nohup.log < /dev/null &
SCRIPT

if conf["chronos_enable"] then
cfg.vm.provision :shell, :privileged => true, :inline => <<-SCRIPT
# Install and run Chronos based on:
# https://mesosphere.io/learn/run-chronos-on-mesos/
mkdir -p /var/log/chronos
LIBPROCESS_IP=#{marathon_ip} nohup /opt/chronos/bin/start-chronos.bash --master #{"zk://"+ninfos[:zk].map{|zk| zk[:ip]+":2181"}.join(",")+"/mesos"} --zk_hosts #{"zk://"+ninfos[:zk].map{|zk| zk[:ip]+":2181"}.join(",")+"/mesos"} --http_port 8081 > /var/log/chronos/nohup.log 2> /var/log/chronos/nohup.log < /dev/null &
SCRIPT
end

# If you wanted use `.dockercfg` file
# Please place the file simply on this directory
if File.exist?(".dockercfg")
config.vm.provision :shell, :priviledged => true, :inline => <<-SCRIPT
cp /vagrant/.dockercfg /root/.dockercfg
chmod 600 /root/.dockercfg
chown root /root/.dockercfg
SCRIPT
end
end
end
end
46 changes: 46 additions & 0 deletions multinodes/cassandra-framework.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"healthChecks": [
{
"timeoutSeconds": 5,
"protocol": "HTTP",
"portIndex": 0,
"path": "/health/cluster",
"maxConsecutiveFailures": 0,
"intervalSeconds": 30,
"gracePeriodSeconds": 120
},
{
"timeoutSeconds": 5,
"protocol": "HTTP",
"portIndex": 0,
"path": "/health/process",
"maxConsecutiveFailures": 3,
"intervalSeconds": 30,
"gracePeriodSeconds": 120
}
],
"id": "/cassandra/dev",
"instances": 1,
"cpus": 0.5,
"mem": 384,
"ports": [
0
],
"uris": [
"https://downloads.mesosphere.io/cassandra-mesos/artifacts/0.2.1-SNAPSHOT-608-master-d1c2cf30c8/cassandra-mesos-0.2.1-SNAPSHOT-608-master-d1c2cf30c8.tar.gz",
"https://downloads.mesosphere.io/java/jre-7u76-linux-x64.tar.gz"
],
"env": {
"CASSANDRA_ZK_TIMEOUT_MS": "10000",
"CASSANDRA_HEALTH_CHECK_INTERVAL_SECONDS": "60",
"MESOS_ZK": "zk://172.31.0.11:2181/mesos",
"JAVA_OPTS": "-Xms256m -Xmx256m",
"CASSANDRA_CLUSTER_NAME": "dev",
"CASSANDRA_ZK": "zk://172.31.0.11:2181/cassandra-mesos1",
"CASSANDRA_NODE_COUNT": "3",
"CASSANDRA_RESOURCE_CPU_CORES": "1",
"CASSANDRA_RESOURCE_MEM_MB": "1024",
"CASSANDRA_RESOURCE_DISK_MB": "2048"
},
"cmd": "$(pwd)/jre*/bin/java $JAVA_OPTS -classpath cassandra-mesos-framework.jar io.mesosphere.mesos.frameworks.cassandra.framework.Main"
}
Loading