Skip to content

Commit 0351b99

Browse files
paulczarcarmstrong
authored andcommitted
docs(openstack): fix instructions
The openstack instructions were a mix of new/old commands and wouldn't work on a lot of openstack installs. These documentation and changes to the provisioning script should allow for more variation in openstack installs. This has been tested as working against both a Havana and Juno release of Openstack.
1 parent 6c88567 commit 0351b99

2 files changed

Lines changed: 78 additions & 31 deletions

File tree

contrib/openstack/README.md

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,32 @@ We greatly appreciate the help!
88
Make sure that the following utilities are installed and in your execution path:
99
- nova
1010
- neutron
11+
- glance
1112

12-
### Configure nova
13+
### Install Deis CLI tools
14+
15+
```console
16+
$ sudo pip install deis
17+
$ curl -sSL http://deis.io/deisctl/install.sh | sh -s 1.0.1
18+
$ mv deisctl /usr/local/bin
19+
$ chmod +x /usr/local/bin/deisctl
20+
```
21+
22+
### Configure openstack
1323
Create an `openrc.sh` file to match the following:
1424
```
15-
[production]
16-
OS_AUTH_URL = {openstack_auth_url}
17-
OS_USERNAME = {openstack_username}
18-
OS_PASSWORD = {openstack_api_key}
19-
OS_TENANT_ID = {openstack_tenant_id}
20-
OS_TENANT_NAME = {openstack_tenant_name}
25+
export OS_AUTH_URL={openstack_auth_url}
26+
export OS_USERNAME={openstack_username}
27+
export OS_PASSWORD={openstack_password}
28+
export OS_TENANT_NAME={openstack_tenant_name}
2129
```
2230

2331
(Alternatively, download OpenStack RC file from Horizon/Access & Security/API Access.)
2432

2533
Source your nova credentials:
2634

2735
```console
28-
# source openrc.sh
36+
$ source openrc.sh
2937
```
3038

3139
### Set up your keys
@@ -35,6 +43,20 @@ Choose an existing keypair or upload a new public key, if desired.
3543
$ nova keypair-add --pub-key ~/.ssh/deis.pub deis-key
3644
```
3745

46+
### Upload a coreos image to Glance
47+
48+
You need to have a relatively recent CoreOS image. If you don't have one and your Openstack install allows you to upload your own images you can do the following:
49+
50+
```console
51+
$ wget http://alpha.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2
52+
$ bunzip2 coreos_production_openstack_image.img.bz2
53+
$ glance image-create --name coreos \
54+
--container-format bare \
55+
--disk-format qcow2 \
56+
--file coreos_production_openstack_image.img \
57+
--is-public True
58+
```
59+
3860
### Customize user-data
3961

4062
Create a user-data file with a new discovery URL this way:
@@ -45,10 +67,11 @@ $ make discovery-url
4567

4668
Or copy [`contrib/coreos/user-data.example`](../coreos/user-data.example) to `contrib/coreos/user-data` and follow the directions in the `etcd:` section to add a unique discovery URL.
4769

48-
### Choose number of instances
49-
By default, the provision script will provision 3 servers. You can override this by setting `DEIS_NUM_INSTANCES`:
70+
### Choose number of instances and routers
71+
5072
```console
51-
$ DEIS_NUM_INSTANCES=5 ./provision-openstack-cluster.sh deis-key
73+
$ export DEIS_NUM_INSTANCES=3
74+
$ export DEIS_NUM_ROUTERS=1
5275
```
5376

5477
Note that for scheduling to work properly, clusters must consist of at least 3 nodes and always have an odd number of members.
@@ -60,6 +83,7 @@ Deis clusters of less than 3 nodes are unsupported.
6083
The script creates a private network called 'deis' if no such network exists.
6184

6285
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:
86+
6387
```console
6488
$ export DEIS_CIDR=10.21.12.0/24
6589
$ export DEIS_DNS=10.21.12.3,8.8.8.8
@@ -68,6 +92,9 @@ $ export DEIS_DNS=10.21.12.3,8.8.8.8
6892
**_Please note that this script does not handle floating IPs or routers. These should be provisioned manually either by Horizon or CLI_**
6993

7094
### Run the provision script
95+
96+
If you have a fairly straight forward openstack install you should be able to use the provisioning script provided. This script assumes you are using neutron and have security-groups enabled.
97+
7198
Run the [Openstack provision script](provision-openstack-cluster.sh) to spawn a new CoreOS cluster.
7299
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.
73100
```console
@@ -77,35 +104,43 @@ Usage: provision-openstack-cluster.sh <coreos image name/id> <key pair name> [fl
77104
$ ./provision-openstack-cluster.sh coreos deis-key
78105
```
79106

80-
### Choose number of routers
81-
By default, the Makefile will provision 1 router. You can override this by setting `DEIS_NUM_ROUTERS`:
82-
```console
83-
$ export DEIS_NUM_ROUTERS=2
107+
You can override the name of the internal network to use by setting the environment variable `DEIS_NETWORK=internal`. If this doesn't exist the script will try to create it with the default CIDR which requires your openstack cluster to support tenant vlans.
108+
109+
You can also override the name of the security group to attach to the instances by setting `DEIS_SECGROUP=deis_test`. If this doesn't exist the script will attempt to create it. If you are creating your own security groups you can use the provision script as a guide. Make sure that you have a rule to enable full communication inside the security group, or you will have a bad day.
110+
111+
### Manually start the instances
112+
113+
### Finish of your openstack configuration by setting up floating IPs.
114+
115+
You will want to attach a floating ip to at least one of your instances. You'll do that like this:
116+
117+
```
118+
$ nova floating-ip-create <pool>
119+
$ nova floating-ip-associate deis-1 <IP provided by above command>
84120
```
85121

86-
## Configure Deis
87-
Set the default domain used to anchor your applications:
122+
### Initialize the cluster
123+
Once the cluster is up:
124+
* **If required, allocate and associate floating IPs to any or all of your hosts**
125+
* Get the IP address of any of the machines from Openstack
126+
* Set the default domain used to anchor your applications:
88127

89128
```console
90129
$ deisctl config platform set domain=mycluster.local
91130
```
92131

93-
For this to work, you'll need to configure DNS records so you can access applications hosted on Deis. See [Configuring DNS](http://docs.deis.io/en/latest/managing_deis/configure-dns/#dns-records) for details.
132+
** For this to work, you'll need to configure DNS records so you can access applications hosted on Deis. See [Configuring DNS](http://docs.deis.io/en/latest/managing_deis/configure-dns/#dns-records) for details.
94133

95-
If you want to allow `deis run` for one-off admin commands, you must provide an SSH private key that allows Deis to gather container logs on CoreOS hosts:
134+
* If you want to allow `deis run` for one-off admin commands, you must provide an SSH private key that allows Deis to gather container logs on CoreOS hosts:
96135

97136
```console
98137
$ deisctl config platform set sshPrivateKey=<path-to-private-key>
99138
```
100139

101-
### Initialize the cluster
102-
Once the cluster is up:
103-
* **If required, allocate and associate floating IPs to any or all of your hosts**
104-
* Get the IP address of any of the machines from Openstack
105-
* set DEISCTL_TUNNEL and install the platform:
140+
* set DEISCTL_TUNNEL to one of your floating IPs and install the platform:
106141

107142
```console
108-
$ export DEISCTL_TUNNEL=23.253.219.94
143+
$ export DEISCTL_TUNNEL=<Floating IP>
109144
$ deisctl install platform && deisctl start platform
110145
```
111146

contrib/openstack/provision-openstack-cluster.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
# Supported environment variables:
66
# DEIS_DNS: Comma separated list of names servers for use in the deis private network (default: none)
77
# DEIS_NUM_INSTANCES: Number of instances to create (default: 3)
8+
# DEIS_NETWORK: name of neutron network to use.
89

910
set -e
1011

1112
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
1213
CONTRIB_DIR=$(dirname $THIS_DIR)
14+
DEIS_NETWORK=${DEIS_NETWORK:-deis}
15+
DEIS_SECGROUP=${DEIS_SECGROUP:-deis}
1316

1417
source $CONTRIB_DIR/utils.sh
1518

@@ -41,18 +44,25 @@ if [ -z "$OS_AUTH_URL" ]; then
4144
exit 1
4245
fi
4346

44-
if ! nova network-list|grep -q deis &>/dev/null; then
47+
if neutron net-list|grep -q $DEIS_NETWORK &>/dev/null; then
48+
NETWORK_ID=$(neutron net-list | grep internal | awk -F'| ' '{print $2}')
49+
else
4550
echo_yellow "Creating deis private network..."
4651
CIDR=${DEIS_CIDR:-10.21.12.0/24}
4752
SUBNET_OPTIONS=""
4853
[ ! -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 : "")}')
54+
NETWORK_ID=$(neutron net-create $DEIS_NETWORK | awk '{ printf "%s", ($2 == "id" ? $4 : "")}')
5055
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 : "")}')
56+
SUBNET_ID=$(neutron subnet-create --name deis_subnet $SUBNET_OPTIONS $NETWORK_ID $CIDR| awk '{ printf "%s", ($2 == "id" ? $4 : "")}')
5457
fi
5558

59+
if ! neutron security-group-list | grep -q $DEIS_SECGROUP &>/dev/null; then
60+
neutron security-group-create $DEIS_SECGROUP
61+
neutron security-group-rule-create --protocol tcp --remote-ip-prefix 0/0 --port-range-min 22 --port-range-max 22 $DEIS_SECGROUP
62+
neutron security-group-rule-create --protocol tcp --remote-ip-prefix 0/0 --port-range-min 2222 --port-range-max 22222 $DEIS_SECGROUP
63+
neutron security-group-rule-create --protocol tcp --remote-ip-prefix 0/0 --port-range-min 80 --port-range-max 80 $DEIS_SECGROUP
64+
neutron security-group-rule-create --protocol icmp --remote-ip-prefix 0/0 $DEIS_SECGROUP
65+
fi
5666

5767
if [ -z "$DEIS_NUM_INSTANCES" ]; then
5868
DEIS_NUM_INSTANCES=3
@@ -63,7 +73,9 @@ $CONTRIB_DIR/util/check-user-data.sh
6373

6474
i=1 ; while [[ $i -le $DEIS_NUM_INSTANCES ]] ; do \
6575
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 ; \
76+
nova boot --image $COREOS_IMAGE --flavor $FLAVOR --key-name $KEYPAIR \
77+
--security-groups $DEIS_SECGROUP --user-data ../coreos/user-data \
78+
--nic net-id=$NETWORK_ID deis-$i ; \
6779
((i = i + 1)) ; \
6880
done
6981

0 commit comments

Comments
 (0)