Skip to content

Commit b952e48

Browse files
committed
refactor(contrib/digitalocean): clean up README, act more like other contrib/ scripts
Updates the README to flow more like the other contrib/ scripts. Also adds a provision-do-cluster.sh
1 parent bb50ad0 commit b952e48

3 files changed

Lines changed: 89 additions & 19 deletions

File tree

contrib/digitalocean/README.md

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,79 @@
1-
# How to Provision a Deis Controller on Digital Ocean
1+
# Provision a Deis Cluster on Digital Ocean
22

3-
Here are the steps to get started on Digital Ocean:
3+
Note that Digital Ocean does not support CoreOS images natively. To work around this, the provision
4+
scripts for Digital Ocean first create a CoreOS image which will be used for provisioning the cluster.
5+
6+
Digital Ocean support was contributed by [sttts](https://github.com/sttts). The CoreOS bootstrapping
7+
is heavily based on [Levi Aul's code](https://gist.github.com/tsutsu/490f35f48897df0f5173).
8+
9+
To deploy Deis to Digital Ocean:
410

511
## Customize cloud-config.yml
612
Edit [user-data](../coreos/user-data) and add a discovery URL. This URL will be used by all nodes in this Deis cluster. You can get a new discovery URL by sending a request to http://discovery.etcd.io/new.
713

8-
## Install DO command line client and authorize:
14+
## Install tugboat and authorize:
15+
The tugboat gem consumes the Digital Ocean API.
916
```console
1017
$ gem install tugboat
1118
$ tugboat authorize
1219
```
1320
You can leave all but the client and API keys as the defaults.
1421

15-
Find out about the ID of your ssh key (import it into DO if it's not listed):
22+
## Upload keys
23+
Choose an SSH keypair to use for Deis and import it to Digital Ocean:
24+
```console
25+
$ tugboat add-key deis
26+
```
27+
28+
Then, get the ID of the key:
1629
```console
1730
$ tugboat keys
1831
```
1932

20-
## Create a controller image:
33+
## Create a Deis image:
2134
```console
22-
$ ./provision-digitalocean-controller-image.sh <YOU SSH KEY ID>
35+
$ ./provision-digitalocean-deis-image.sh <SSH KEY ID>
2336
```
2437

25-
## Deploy controllers
26-
Use the created image to launch (an odd number) controller droplets, either via UI
27-
or on the command line using tugboat:
38+
## Choose number of instances
39+
By default, the script will provision 3 servers. You can override this by setting `DEIS_NUM_INSTANCES`:
40+
```console
41+
$ export DEIS_NUM_INSTANCES=5
42+
```
43+
44+
Note that for scheduling to work properly, clusters must consist of at least 3 nodes and always have an odd number of members.
45+
For more information, see [optimal etcd cluster size](https://github.com/coreos/etcd/blob/master/Documentation/optimal-cluster-size.md).
46+
47+
Deis clusters of less than 3 nodes are unsupported.
48+
49+
## Deploy cluster
50+
Run the provision script:
2851
```console
29-
$ tugboat create deis1 -r <REGION_ID> -i <IMAGE_ID> -p true -k <SSH_ID> -s 65
52+
$ ./provision-do-cluster.sh <REGION_ID> <IMAGE_ID> <SSH_ID> <SIZE>
3053
```
3154

3255
Not all regions allow private networks. Choose one which does, e.g. NY 2, Amsterdam 2 or
3356
Singapore 1 at the time of this writing (check the web UI for the current private network
34-
support).
57+
support). You can enumerate all the regions with:
3558

36-
The provisioning script uses a 512 MB droplet by default because for iamge creation
59+
```console
60+
$ tugboat regions
61+
```
62+
63+
The provisioning script uses a 512 MB droplet by default because for image creation
3764
more memory is not needed. Deis controller nodes will need at least 2 GB to even start all
38-
the services. Add the memory requirements of deployed applications and choose an adequat
39-
droplet size, e.g. 8 GB (ID "65").
65+
the services. Add the memory requirements of deployed applications and choose an adequate
66+
droplet size. The default is 8 GB (ID "65"). You can enumerate all sizes with:
67+
68+
```console
69+
$ tugboat sizes
70+
```
71+
72+
## Choose number of routers
73+
By default, the Makefile will provision 1 router. You can override this by setting `DEIS_NUM_ROUTERS`:
74+
```console
75+
$ export DEIS_NUM_ROUTERS=2
76+
```
4077

4178
## Initialize the cluster
4279
Once the cluster is up, get the IPs of any of the machines using `tugboat droplets`, set
@@ -63,7 +100,7 @@ email: info@opdemand.com
63100
## Hack on Deis
64101
If you'd like to use this deployment to build Deis, you'll need to set `DEIS_HOSTS` to an array of your cluster hosts:
65102
```console
66-
$ export DEIS_HOSTS=10.21.12.1 10.21.12.2 10.21.12.3
103+
$ DEIS_HOSTS="1.2.3.4 2.3.4.5 3.4.5.6" make build
67104
```
68105

69106
This variable is used in the `make build` command.

contrib/digitalocean/provision-digitalocean-controller-image.sh renamed to contrib/digitalocean/provision-digitalocean-deis-image.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ done
9999
echo_green "done"
100100

101101
echo
102-
echo_green "Congratulations: The Deis controller image $NAME was created with ID $IMAGE_ID."
102+
echo_green "Congratulations: The Deis image $NAME was created with ID $IMAGE_ID."
103103
echo
104-
echo "Spawn controllers with:"
105-
echo
106-
echo " tugboat create deis1 -i $IMAGE_ID -r $REGION -p true -k $SSH_ID -s 65"
104+
echo_yellow "Launch the cluster with: ./provision-do-cluster.sh $REGION $IMAGE_ID $SSH_ID 65"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage: ./provision-do-cluster.sh <REGION_ID> <IMAGE_ID> <SSH_ID> <SIZE>
4+
#
5+
6+
set -e
7+
8+
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
9+
CONTRIB_DIR=$(dirname $THIS_DIR)
10+
11+
source $CONTRIB_DIR/utils.sh
12+
13+
# check for DO tools in $PATH
14+
if ! which tugboat > /dev/null; then
15+
echo_red 'Please install the tugboat gem and ensure it is in your $PATH.'
16+
exit 1
17+
fi
18+
19+
if [ -z "$DEIS_NUM_INSTANCES" ]; then
20+
DEIS_NUM_INSTANCES=3
21+
fi
22+
23+
# check that the CoreOS user-data file is valid
24+
$CONTRIB_DIR/util/check-user-data.sh
25+
26+
# launch the Deis cluster on Digital Ocean
27+
i=1 ; while [[ $i -le $DEIS_NUM_INSTANCES ]] ; do \
28+
NAME=deis-$i
29+
echo_yellow "Provisioning ${NAME}..."
30+
tugboat create $NAME -r $1 -i $2 -p true -k $3 -s $4
31+
((i = i + 1)) ; \
32+
done
33+
34+
echo_green "Your Deis cluster has successfully deployed to Digital Ocean."
35+
echo_green "Please continue to follow the instructions in the README."

0 commit comments

Comments
 (0)