Răsfoiți Sursa

started working on Vagrant + mesos

Harlan Iverson 8 ani în urmă
părinte
comite
5660415a78

+ 7 - 0
README.md

@@ -27,6 +27,13 @@ A baseline Clojure stack that runs on any and all platforms, that is nice to dev
 * No bullshit (pull request if you disagree)
 
 
+
+## Quick Start
+
+    vagrant up && vagrant ssh
+    curl -i -H 'Content-Type: application/json' -d @/develop/marathon-apps/check-env.json localhost:8080/v2/apps
+
+
 ![Architecture Sketch](doc/clojure-everywhere.jpg)
 
 

+ 131 - 0
Vagrantfile

@@ -0,0 +1,131 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  # All Vagrant configuration is done here. The most common configuration
+  # options are documented and commented below. For a complete reference,
+  # please see the online documentation at vagrantup.com.
+
+  # Every Vagrant virtual environment requires a box to build off of.
+  config.vm.box = "ubuntu/trusty64"
+
+  config.vm.hostname = "clojure-stack"
+
+  config.vm.post_up_message = "HI! WRITE ME IN Vagrantfile"
+
+  # Disable automatic box update checking. If you disable this, then
+  # boxes will only be checked for updates when the user runs
+  # `vagrant box outdated`. This is not recommended.
+  # config.vm.box_check_update = false
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # config.vm.network "forwarded_port", guest: 80, host: 8080
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  config.vm.network "private_network", ip: "192.168.33.33"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network "public_network"
+
+  # If true, then any SSH connections made will enable agent forwarding.
+  # Default value: false
+  config.ssh.forward_agent = true
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  config.vm.synced_folder ".", "/develop"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  config.vm.provider "virtualbox" do |vb|
+  #   # Don't boot with headless mode
+  #   vb.gui = true
+  #
+  #   # Use VBoxManage to customize the VM. For example to change memory:
+    #vb.customize ["modifyvm", :id, "--memory", "4096"]
+    vb.memory = 5120
+    vb.cpus = 2
+  end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
+
+  # Enable provisioning with CFEngine. CFEngine Community packages are
+  # automatically installed. For example, configure the host as a
+  # policy server and optionally a policy file to run:
+  #
+  # config.vm.provision "cfengine" do |cf|
+  #   cf.am_policy_hub = true
+  #   # cf.run_file = "motd.cf"
+  # end
+  #
+  # You can also configure and bootstrap a client to an existing
+  # policy server:
+  #
+  # config.vm.provision "cfengine" do |cf|
+  #   cf.policy_server_address = "10.0.2.15"
+  # end
+
+  # Enable provisioning with Puppet stand alone.  Puppet manifests
+  # are contained in a directory path relative to this Vagrantfile.
+  # You will need to create the manifests directory and a manifest in
+  # the file default.pp in the manifests_path directory.
+  #
+  # config.vm.provision "puppet" do |puppet|
+  #   puppet.manifests_path = "manifests"
+  #   puppet.manifest_file  = "default.pp"
+  # end
+
+  # Enable provisioning with chef solo, specifying a cookbooks path, roles
+  # path, and data_bags path (all relative to this Vagrantfile), and adding
+  # some recipes and/or roles.
+  #
+  # config.vm.provision "chef_solo" do |chef|
+  #   chef.cookbooks_path = "../my-recipes/cookbooks"
+  #   chef.roles_path = "../my-recipes/roles"
+  #   chef.data_bags_path = "../my-recipes/data_bags"
+  #   chef.add_recipe "mysql"
+  #   chef.add_role "web"
+  #
+  #   # You may also specify custom JSON attributes:
+  #   chef.json = { mysql_password: "foo" }
+  # end
+
+  # Enable provisioning with chef server, specifying the chef server URL,
+  # and the path to the validation key (relative to this Vagrantfile).
+  #
+  # The Opscode Platform uses HTTPS. Substitute your organization for
+  # ORGNAME in the URL and validation key.
+  #
+  # If you have your own Chef Server, use the appropriate URL, which may be
+  # HTTP instead of HTTPS depending on your configuration. Also change the
+  # validation key to validation.pem.
+  #
+  # config.vm.provision "chef_client" do |chef|
+  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+  #   chef.validation_key_path = "ORGNAME-validator.pem"
+  # end
+
+  config.vm.provision "shell", path: "provision.sh"
+
+  #
+  # If you're using the Opscode platform, your validator client is
+  # ORGNAME-validator, replacing ORGNAME with your organization name.
+  #
+  # If you have your own Chef Server, the default validation client name is
+  # chef-validator, unless you changed the configuration.
+  #
+  #   chef.validation_client_name = "ORGNAME-validator"
+end

+ 7 - 0
marathon-apps/check-env.json

@@ -0,0 +1,7 @@
+{"id": "check-env",
+ "env": {"DEVELOP_DIR": "/develop"},
+ "fetch": [{"uri": "file:///develop/project.clj"}],
+ "ports": [0],
+ "cmd": "watch \"echo $PORT && java -version && ls -la $DEVELOP_DIR && ls -la .\"",
+ "cpus": 0.1,
+ "mem": 16}

+ 14 - 0
marathon-apps/clojure-stack.json

@@ -0,0 +1,14 @@
+{"id": "/clojure-stack",
+  "env": {"DEVELOP": "/develop"},
+  "apps": [{"id": "/clojure-stack/web-backend",
+            "env": {"JAVA_OPTS": "-Xms128m -Xmx256m",
+                    "JAR": "/develop/web-backend/target/web-backend-0.0.1-SNAPSHOT-standalone.jar"},
+            "ports": [0],
+            "cmd": "java $JAVA_OPTS -jar $JAR",
+            "cpus": 0.1,
+            "mem": 256,
+            "instances": 3},
+           {"id": "/clojure-stack/check-env",
+            "cmd": "watch \"echo $DEVELOP && ls -la .\"",
+            "cpus": 0.1,
+            "mem": 16}]}

+ 23 - 0
marathon-apps/mesos-dns-config.json

@@ -0,0 +1,23 @@
+{
+  "zk": "zk://clojure-stack:2181/mesos",
+  "masters": ["clojure-stack:5050"],
+  "refreshSeconds": 60,
+  "ttl": 60,
+  "domain": "mesos",
+  "ns": "ns1",
+  "port": 53,
+  "resolvers": ["8.8.8.8"],
+  "timeout": 5,
+  "listener": "0.0.0.0",
+  "SOAMname": "root.ns1.mesos",
+  "SOARname": "ns1.mesos",
+  "SOARefresh": 60,
+  "SOARetry":   600,
+  "SOAExpire":  86400,
+  "SOAMinttl": 60,
+  "dnson": true,
+  "httpon": true,
+  "httpport": 8123,
+  "externalon": true,
+  "recurseon": true
+}

+ 9 - 0
marathon-apps/mesos-dns.json

@@ -0,0 +1,9 @@
+// not working yet
+
+{"id": "mesos-dns",
+ "env": {"DEVELOP": "/develop"},
+ "cmd": "sudo $DEVELOP/mesos-dns -config=$DEVELOP/marathon-apps/mesos-dns-config.json",
+ "cpus": 0.1,
+ "mem": 128,
+ "instances": 1,
+ "constraints": [["hostname", "CLUSTER", "192.168.33.33 "]]}

+ 63 - 0
provision.sh

@@ -0,0 +1,63 @@
+#!/bin/sh
+
+#export HOSTNAME="mesos"
+#echo $HOSTNAME | sudo tee /etc/hostname
+#sudo hostname -F /etc/hostname
+
+
+
+# Java repos
+echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
+echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
+sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EEA14886
+
+
+# Marathon repos
+DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
+CODENAME=$(lsb_release -cs)
+echo "deb http://repos.mesosphere.com/${DISTRO} ${CODENAME} main" | \
+  sudo tee /etc/apt/sources.list.d/mesosphere.list
+sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E56151BF
+sudo apt-get -y update
+
+sudo apt-get -y install oracle-java8-installer mesos marathon
+
+
+
+# scala
+
+wget http://downloads.typesafe.com/scala/2.10.6/scala-2.10.6.deb \
+ && sudo dpkg -i scala-2.10.6.deb \
+ && rm scala-2.10.6.deb
+
+
+# kafka mesos
+
+sudo apt-get -y install git
+git clone git clone https://github.com/mesos/kafka kafka-mesos \
+ && cd kafka-mesos \
+ && git checkout v0.9.2.0 \
+ && ./gradlew jar -xtest \
+ && wget https://archive.apache.org/dist/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz \
+ && cd ..
+
+export MESOS_NATIVE_JAVA_LIBRARY=/usr/local/lib/libmesos.so
+export LIBPROCESS_IP=127.0.0.1
+
+
+./kafka-mesos.sh broker add 0 --heap 256 --mem 384 --cpus 0.1
+
+
+# mesos-dns
+
+
+curl -L -o /develop/mesos-dns https://github.com/mesosphere/mesos-dns/releases/download/v0.5.1/mesos-dns-v0.5.1-linux-amd64
+chmod a+x /develop/mesos-dns
+
+sudo sed -i '1s/^/nameserver clojure-stack\n /' /etc/resolv.conf
+
+sudo service zookeeper restart
+sudo service mesos start
+sudo service marathon start
+
+