Last active
August 29, 2015 14:24
-
-
Save philwinder/0747a889b18b9f812d07 to your computer and use it in GitHub Desktop.
Shell script for Container Solutions Software Circus Meetup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################ | |
# Introduction # | |
# This script is a demo of DCOS for the Container Solutions hosted Software Circus meetup. | |
# Don't run this as a script, it expects the DCOS CLI installed. Rather you should work | |
# through the examples one by one. | |
# Prerequisites: | |
# - A working DCOS cluster on AWS. See https://mesosphere.com/amazon/setup/ | |
# Please make sure you enter your master AWS IP below. | |
export DCOSMASTER=52.18.26.47 | |
# View web UI's | |
## DCOS | |
echo "DOCS url: http://${DCOSMASTER}/" | |
## Marathon | |
echo "Marathon url: http://${DCOSMASTER}:8080/" | |
## Mesos | |
echo "Mesos url: http://${DCOSMASTER}:5050/" | |
# Install CLI from | |
# https://docs.mesosphere.com/install/cli/ | |
## CD into dcos folder (where you have installed it) | |
cd /Volumes/source/dcos | |
# Setup | |
## Source DCOS so we can run the command | |
source /Volumes/source/dcos/bin/env-setup && dcos help | |
## Set DCOS URL | |
dcos config set core.dcos_url http://${DCOSMASTER}/ | |
# If we were to use the ES project, then we would add that as a source | |
dcos config prepend package.sources "https://github.com/trifork-leeds/universe/archive/version-1.x.zip" | |
dcos package sources | |
# Remove package | |
dcos config unset package.sources --index=0 | |
# Update packages | |
dcos package update | |
################# | |
# SPARK EXAMPLE # | |
## Install spark | |
## Note, takes a few minutes to download, so don't do this live. | |
dcos package install spark | |
## View spark web | |
dcos spark webui | |
## Calculate pi! | |
dcos spark run --submit-args='-Dspark.mesos.coarse=true --driver-cores 1 --driver-memory 256M --class org.apache.spark.examples.SparkPi http://downloads.mesosphere.com.s3.amazonaws.com/assets/spark/spark-examples_2.10-1.4.0-SNAPSHOT.jar 1000' | |
################## | |
# WEBAPP EXAMPLE # | |
## Add JSON marathon command | |
echo '{ | |
"container": { | |
"type": "DOCKER", | |
"docker": { | |
"image": "superguenter/demo-app" | |
} | |
}, | |
"cmd": "python -m SimpleHTTPServer $PORT", | |
"id": "demo", | |
"cpus": 0.01, | |
"mem": 256, | |
"ports": [3000] | |
}' > example.json | |
dcos marathon app add example.json | |
## List | |
dcos marathon app list | |
## Tunnel into slave to view web gui | |
/Volumes/source/tunnelIntoWeb.sh ${DCOSMASTER} 10.0.0.176 3000 | |
http://localhost:3000/ | |
## Scale up | |
dcos marathon app update demo instances=100 | |
## Kill a load of random processes | |
/Volumes/source/tunnelInto.sh ${DCOSMASTER} 10.0.0.176 | |
sudo kill -9 $(ps -ax | grep "docker wait" | awk -F ' ' '{print $1}') | |
## Scale down | |
dcos marathon app update demo instances=1 | |
# Stop | |
dcos marathon app stop demo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment