-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprovision-do-cluster.sh
More file actions
executable file
·73 lines (58 loc) · 1.8 KB
/
provision-do-cluster.sh
File metadata and controls
executable file
·73 lines (58 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
#
# Usage: ./provision-do-cluster.sh <REGION_ID> <SSH_ID> <SIZE>
#
set -e
listcontains() {
for i in $1; do
[[ $i = $2 ]] && return 0
done
return 1
}
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
CONTRIB_DIR=$(dirname $THIS_DIR)
REGION_SLUG=$1
SSH_ID=$2
SIZE=$3
PREFIX=$4
if [ -z "$PREFIX" ]; then
PREFIX="deis"
fi
source $CONTRIB_DIR/utils.sh
if [ -z "$3" ]; then
echo_red 'Usage: provision-do-cluster.sh <REGION_SLUG> <SSH_ID> <SIZE> [PREFIX]'
exit 1
fi
# check for DO tools in $PATH
if ! which docl > /dev/null; then
echo_red 'Please install the docl gem and ensure it is in your $PATH.'
exit 1
fi
if [ -z "$DEIS_NUM_INSTANCES" ]; then
DEIS_NUM_INSTANCES=3
fi
regions_without_private_networking_or_metadata="nyc1 nyc2 ams1"
if listcontains "$regions_without_private_networking_or_metadata" "$REGION_SLUG";
then
echo_red "Invalid region. Please supply a region with private networking & metadata support."
echo_red "Valid regions are (use the name in brackets):"
docl regions --private_networking --metadata
exit 1
fi
# check that the CoreOS user-data file is valid
$CONTRIB_DIR/util/check-user-data.sh
# TODO: Make it follow a specific ID once circumstances allow us to do so.
BASE_IMAGE_ID='coreos-stable'
if [ -z "$BASE_IMAGE_ID" ]; then
echo_red "DigitalOcean Image not found..."
exit 1
fi
# launch the Deis cluster on DigitalOcean
i=1 ; while [[ $i -le $DEIS_NUM_INSTANCES ]] ; do \
NAME="$PREFIX-$i"
echo_yellow "Provisioning ${NAME}..."
docl create $NAME $BASE_IMAGE_ID $SIZE $REGION_SLUG --key=$SSH_ID --private-networking --user-data=$CONTRIB_DIR/coreos/user-data --wait
((i = i + 1)) ; \
done
echo_green "Your Deis cluster has successfully deployed to DigitalOcean."
echo_green "Please continue to follow the instructions in the README."