Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
upgrade the Rackspace prepare, provision, and provider scripts to use…
Browse files Browse the repository at this point in the history
… newer Rackspace performance flavors
  • Loading branch information
stackedsax authored and mboersma committed Jan 14, 2014
1 parent ad22b6c commit 8d21adc
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 66 deletions.
124 changes: 66 additions & 58 deletions contrib/rackspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,81 @@ Provision a Deis Controller on Rackspace

1. Install [knife-rackspace][kniferack] with `gem install knife-rackspace` or just `bundle install` from the root directory of your deis repository:

```console
$ cd $HOME/projects/deis
$ gem install knife-rackspace
Fetching: knife-rackspace-0.8.1.gem (100%)
Successfully installed knife-rackspace-0.8.1
1 gem installed
Installing ri documentation for knife-rackspace-0.8.1...
Installing RDoc documentation for knife-rackspace-0.8.1...
```
```console
$ cd $HOME/projects/deis
$ gem install knife-rackspace
Fetching: knife-rackspace-0.8.1.gem (100%)
Successfully installed knife-rackspace-0.8.1
1 gem installed
Installing ri documentation for knife-rackspace-0.8.1...
Installing RDoc documentation for knife-rackspace-0.8.1...
```

2. Export your Rackspace credentials as environment variables and edit knife.rb to read them:
1. Export your Rackspace credentials as environment variables and edit knife.rb to read them:

```console
$ cat <<'EOF' >> $HOME/.bash_profile
export RACKSPACE_USERNAME=<your_rackspace_username>
export RACKSPACE_API_KEY=<your_rackspace_api_key>
EOF
$ source $HOME/.bash_profile
$ cat <<'EOF' >> $HOME/.chef/knife.rb
knife[:rackspace_api_username] = "#{ENV['RACKSPACE_USERNAME']}"
knife[:rackspace_api_key] = "#{ENV['RACKSPACE_API_KEY']}"
EOF
$ knife rackspace server list
Instance ID Name Public IP Private IP Flavor Image State
```
```console
$ cat <<'EOF' >> $HOME/.bash_profile
export RACKSPACE_USERNAME=<your_rackspace_username>
export RACKSPACE_API_KEY=<your_rackspace_api_key>
EOF
$ source $HOME/.bash_profile
$ cat <<'EOF' >> $HOME/.chef/knife.rb
knife[:rackspace_api_username] = "#{ENV['RACKSPACE_USERNAME']}"
knife[:rackspace_api_key] = "#{ENV['RACKSPACE_API_KEY']}"
EOF
$ knife rackspace server list
Instance ID Name Public IP Private IP Flavor Image State
```

3. Prepare an new image.
* This will be used as the image to create a new controller as well as new nodes in a formation.
1. Prepare a new server
1. Create a server named `deis_prepare_image` using the Ubuntu 12.04 LTS image, performance1-2, 1GB performance server
1. SSH in as root with the password shown
1. Install the 3.8 kernel with: ```apt-get update && apt-get install -yq linux-image-generic-lts-raring linux-headers-generic-lts-raring && reboot```
1. After reboot is complete, SSH back in as root and `uname -r` to confirm kernel is `3.8.0-35-generic`
1. Run the `prepare-rackspace-image.sh` script to optimize the image for fast boot times

```console
$ ./contrib/rackspace/prepare-rackspace-image.sh
+ dpkg -l 'linux-*'
+ xargs sudo apt-get -y purge
++ uname -r
++ sed 's/\(.*\)-\([^0-9]\+\)/\1/'
...
+ rm -f /root/.ssh/authorized_keys
+ find /var/log -type f
+ xargs rm
+ sync
```
```console
$ ./contrib/rackspace/prepare-rackspace-image.sh
+ dpkg -l 'linux-*'
+ xargs sudo apt-get -y purge
++ uname -r
++ sed 's/\(.*\)-\([^0-9]\+\)/\1/'
...
+ rm -f /root/.ssh/authorized_keys
+ find /var/log -type f
+ xargs rm
+ sync
```

4. Run the provisioning script to create a new Deis controller:
* Change ```<region>``` to be one of:
1. Create a new image from the server named "deis-base-image".
1. In the server list in the Control Panel click the action cog for `deis_prepare_image`
1. Select "Create New Image" name that image "deis-base-image"
1. (optionally) Distribute the image to other regions
1. (optionally) Create/update your Deis flavors to use your new images

1. Run the provisioning script to create a new Deis controller:
* Change ```<region>``` to match the region your image is in:
* dfw
* ord
* iad
* lon
* syd
* hkg

```console
$ ./contrib/rackspace/provision-rackspace-controller.sh <region>
Provisioning a deis controller on Rackspace...
Creating new SSH key: deis-controller
+ ssh-keygen -f /home/myuser/.ssh/deis-controller -t rsa -N '' -C deis-controller
+ set +x
Saved to /home/myuser/.ssh/deis-controller
Created data_bag[deis-users]
Created data_bag[deis-formations]
Created data_bag[deis-apps]
Provisioning deis-controller with knife rackspace...
+ knife rackspace server create -y --server-create-timeout 1200 --server-name deis-controller --image 4b7c635d-89e1-44be-a15f-2877b5a660d1 --rackspace-region <region> --flavor 4 --identity-file /home/myuser/.ssh/deis-controller --bootstrap-version 11.4.4 --node-name deis-controller --run-list 'recipe[deis::controller]'
Instance ID: de17ca36-f186-4cdd-8969-4be58e7108ea
Name: deis-controller
Flavor: 2GB Standard Instance
...
```
```console
$ ./contrib/rackspace/provision-rackspace-controller.sh <region>
Provisioning a deis controller on Rackspace...
Creating new SSH key: deis-controller
+ ssh-keygen -f /home/myuser/.ssh/deis-controller -t rsa -N '' -C deis-controller
+ set +x
Saved to /home/myuser/.ssh/deis-controller
Created data_bag[deis-users]
Created data_bag[deis-formations]
Created data_bag[deis-apps]
Provisioning deis-controller with knife rackspace...
+ knife rackspace server create -y --server-create-timeout 1200 --server-name deis-controller --image 4b7c635d-89e1-44be-a15f-2877b5a660d1 --rackspace-region <region> --flavor 4 --identity-file /home/myuser/.ssh/deis-controller --bootstrap-version 11.4.4 --node-name deis-controller --run-list 'recipe[deis::controller]'
Instance ID: de17ca36-f186-4cdd-8969-4be58e7108ea
Name: deis-controller
Flavor: 2GB Standard Instance
...
```

[kniferack]: http://docs.opscode.com/plugin_knife_rackspace.html
2 changes: 1 addition & 1 deletion contrib/rackspace/prepare-rackspace-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Instructions:
#
# 1. Create a server using the Ubuntu 12.04 LTS image,
# type 2 (512MB Standard Instance), Disk Partitioning: Manual.
# performance1-2, 2GB performance server
# 2. SSH in as root with the password shown, then install the 3.8 kernel with:
# apt-get update && apt-get install -yq linux-image-generic-lts-raring linux-headers-generic-lts-raring && reboot
# 3. After reboot is complete, SSH in and `uname -r` to confirm kernel is 3.8
Expand Down
6 changes: 3 additions & 3 deletions contrib/rackspace/provision-rackspace-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ chef_version=11.6.2
region=$1
# see contrib/prepare-rackspace-image.sh for instructions
# on creating your own deis-optmized images
if ! [[ "ord dfw iad lon syd" =~ $region ]]; then
# TODO: add syd and hkg when they gain performance flavors in early 2014
if ! [[ "ord dfw iad lon" =~ $region ]]; then
echo "Unrecognized region: $region"
exit 1
fi
flavor=$(knife rackspace flavor list | grep '2GB Standard Instance' | awk '{print $1}')
flavor='performance1-2'
image=$(knife rackspace image list --rackspace-region $region | grep 'deis-base-image' | awk '{print $1}')
if [[ -z $image ]]; then
echo "Can't find saved image \"deis-base-image\" in region $region. Please follow the"
Expand Down Expand Up @@ -85,7 +86,6 @@ knife rackspace server create \
--image $image \
--flavor $flavor \
--rackspace-metadata "{\"Name\": \"$node_name\"}" \
--rackspace-disk-config MANUAL \
--identity-file $ssh_key_path \
--server-name $node_name \
--node-name $node_name \
Expand Down
10 changes: 6 additions & 4 deletions provider/rackspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
import pyrax

# TODO: this seems like a bad import, but can't update the layer
# coorrectly otherwise.
# correctly otherwise.
from api.models import Layer


logger = logging.getLogger(__name__)

## TODO: add syd and hkg when they gain performance flavors in early 2014
RACKSPACE_REGIONS = {
'dfw': 'Dallas',
'iad': 'Northern Virginia',
'ord': 'Chicago',
'lon': "London",
'syd': 'Sydney',
'lon': 'London',
#'syd': 'Sydney',
#'hkg': 'Hong Kong',
}

RACKSPACE_DEFAULT_REGION = 'dfw'
Expand All @@ -40,7 +42,7 @@ def seed_flavors():
'params': json.dumps({
'region': r,
# 'image': ?
'flavor': 4, # 2GB Standard Instance, 2 VCPUs, 2048 / 80GB
'flavor': 'performance1-2', # 2GB Performance Instance, 2 VCPUs, 2048 / 80GB
})
})
return flavors
Expand Down

0 comments on commit 8d21adc

Please sign in to comment.