Skip to content

Commit e004275

Browse files
shakimcarmstrong
authored andcommitted
feat(contrib/openstack): script for deploying deis on OpenStack
1 parent 20a0a98 commit e004275

2 files changed

Lines changed: 179 additions & 0 deletions

File tree

contrib/openstack/README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Provision a Deis Cluster on OpenStack
2+
3+
4+
### Prerequisites:
5+
Make sure that the following utilities are installed and in your execution path:
6+
- nova
7+
- neutron
8+
9+
### Configure nova
10+
Create an `openrc.sh` file to match the following:
11+
```
12+
[production]
13+
OS_AUTH_URL = {openstack_auth_url}
14+
OS_USERNAME = {openstack_username}
15+
OS_PASSWORD = {openstack_api_key}
16+
OS_TENANT_ID = {openstack_tenant_id}
17+
OS_TENANT_NAME = {openstack_tenant_name}
18+
```
19+
20+
(Alternatively, download OpenStack RC file from Horizon/Access & Security/API Access.)
21+
22+
Source your nova credentials:
23+
24+
```console
25+
# source openrc.sh
26+
```
27+
28+
### Set up your keys
29+
Choose an existing keypair or upload a new public key, if desired.
30+
31+
```console
32+
$ nova keypair-add --pub-key ~/.ssh/deis.pub deis-key
33+
```
34+
35+
### Customize cloud-config.yml
36+
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.
37+
38+
### Choose number of instances
39+
By default, the provision script will provision 3 servers. You can override this by setting `DEIS_NUM_INSTANCES`:
40+
```console
41+
$ DEIS_NUM_INSTANCES=5 ./provision-rackspace-cluster.sh deis-key
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+
### Deis network settings
50+
The script creates a private network called 'deis' if no such network exist.
51+
52+
By default, the deis subnet IP range is set to 10.21.12.0/24. To override it and the default DNS settings, set the following variables:
53+
```console
54+
$ export DEIS_CIDR=10.21.12.0/24
55+
$ export DEIS_DNS=10.21.12.3,8.8.8.8
56+
```
57+
58+
**_Please note that this script does not handle floating IPs or routers. These should be provisioned manually either by Horizon or CLI_**
59+
60+
### Run the provision script
61+
Run the [Openstack provision script](provision-openstack-cluster.sh) to spawn a new CoreOS cluster.
62+
You'll need to provide the name of the CoreOS image name (or ID), and the key pair you just added. Optionally, you can also specify a flavor name.
63+
```console
64+
$ cd contrib/openstack
65+
$ ./provision-openstack-cluster.sh
66+
Usage: provision-rackspace-cluster.sh <coreos image name/id> <key pair name> [flavor]
67+
$ ./provision-rackspace-cluster.sh coreos deis-key
68+
```
69+
70+
### Choose number of routers
71+
By default, the Makefile will provision 1 router. You can override this by setting `DEIS_NUM_ROUTERS`:
72+
```console
73+
$ export DEIS_NUM_ROUTERS=2
74+
```
75+
76+
### Initialize the cluster
77+
Once the cluster is up:
78+
* **If required, allocate and associate floating IPs to any or all of your hosts**
79+
* Get the IP address of any of the machines from Openstack
80+
* set FLEETCTL_TUNNEL, and issue a `make run` from the project root:
81+
82+
```console
83+
$ export FLEETCTL_TUNNEL=23.253.219.94
84+
$ cd ../.. && make run
85+
```
86+
87+
The script will deploy Deis and make sure the services start properly.
88+
89+
### Configure DNS
90+
You'll need to configure DNS records so you can access applications hosted on Deis. See [Configuring DNS](http://docs.deis.io/en/latest/installing_deis/configure-dns/) for details.
91+
92+
### Use Deis!
93+
After that, register with Deis!
94+
```console
95+
$ deis register http://deis.example.org
96+
username: deis
97+
password:
98+
password (confirm):
99+
email: info@opdemand.com
100+
```
101+
102+
## Hack on Deis
103+
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:
104+
```console
105+
$ DEIS_HOSTS="1.2.3.4 2.3.4.5 3.4.5.6" make build
106+
```
107+
108+
This variable is used in the `make build` command.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage: ./provision-rackspace-cluster.sh <key pair name> [flavor]
4+
#
5+
# Supported environment variables:
6+
# DEIS_DNS: Comma separated list of names servers for use in the deis private network (default: none)
7+
# DEIS_NUM_INSTANCES: Number of instances to create (default: 3)
8+
9+
set -e
10+
11+
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
12+
CONTRIB_DIR=$(dirname $THIS_DIR)
13+
14+
source $CONTRIB_DIR/utils.sh
15+
16+
if [ -z "$2" ]; then
17+
echo_red 'Usage: provision-openstack-cluster.sh <coreos image name/id> <key pair name> [flavor]'
18+
exit 1
19+
fi
20+
COREOS_IMAGE=$1
21+
KEYPAIR=$2
22+
23+
if ! which nova > /dev/null; then
24+
echo_red 'Please install nova and ensure it is in your $PATH.'
25+
exit 1
26+
fi
27+
28+
if ! which neutron > /dev/null; then
29+
echo_red 'Please install neutron and ensure it is in your $PATH.'
30+
exit 1
31+
fi
32+
33+
if [ -z "$3" ]; then
34+
FLAVOR="m1.large"
35+
else
36+
FLAVOR=$3
37+
fi
38+
39+
if [ -z "$OS_AUTH_URL" ]; then
40+
echo_red "nova credentials are not set. Please source openrc.sh"
41+
exit 1
42+
fi
43+
44+
if ! nova network-list|grep -q deis &>/dev/null; then
45+
echo_yellow "Creating deis private network..."
46+
CIDR=${DEIS_CIDR:-10.21.12.0/24}
47+
SUBNET_OPTIONS=""
48+
[ ! -z "$DEIS_DNS" ] && SUBNET_OPTIONS=$(echo $DEIS_DNS|awk -F "," '{for (i=1; i<=NF; i++) printf "--dns-nameserver %s ", $i}')
49+
NETWORK_ID=$(neutron net-create deis | awk '{ printf "%s", ($2 == "id" ? $4 : "")}')
50+
echo "DBG: SUBNET_OPTIONS=$SUBNET_OPTIONS"
51+
SUBNET_ID=$(neutron subnet-create --name deis_subnet $SUBNET_OPTIONS deis $CIDR| awk '{ printf "%s", ($2 == "id" ? $4 : "")}')
52+
else
53+
NETWORK_ID=$(neutron net-list | awk '{printf "%s", ($4 == "deis" ? $2 : "")}')
54+
fi
55+
56+
57+
if [ -z "$DEIS_NUM_INSTANCES" ]; then
58+
DEIS_NUM_INSTANCES=3
59+
fi
60+
61+
# check that the CoreOS user-data file is valid
62+
$CONTRIB_DIR/util/check-user-data.sh
63+
64+
i=1 ; while [[ $i -le $DEIS_NUM_INSTANCES ]] ; do \
65+
echo_yellow "Provisioning deis-$i..."
66+
nova boot --image $COREOS_IMAGE --flavor $FLAVOR --key-name $KEYPAIR --user-data ../coreos/user-data --nic net-id=$NETWORK_ID deis-$i ; \
67+
((i = i + 1)) ; \
68+
done
69+
70+
echo_green "Your Deis cluster has successfully deployed to OpenStack."
71+
echo_green "Please continue to follow the instructions in the README."

0 commit comments

Comments
 (0)