Skip to content

Commit 56c28e1

Browse files
mboersmaGabriel Monroy
authored andcommitted
Updated DigitalOcean scripts for containerize support.
1 parent 4edac55 commit 56c28e1

5 files changed

Lines changed: 137 additions & 88 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash -ex
2+
3+
#
4+
# Prepare a Deis-optimized Controller image from a vanilla Ubuntu 12.04 droplet
5+
#
6+
# Instructions:
7+
#
8+
# 1. Launch a vanilla Ubuntu 12.04.3 droplet (64-bit)
9+
# 2. Run this script (as root!) to optimize the image for faster provisioning
10+
# 3. Create a new snapshot named "deis-controller-base" from this droplet
11+
#
12+
13+
# Remove old kernel(s)
14+
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
15+
16+
# Add the Docker repository key to your local keychain
17+
# using apt-key finger you can check the fingerprint matches 36A1 D786 9245 C895 0F96 6E92 D857 6A8B A88D 21E9
18+
curl https://get.docker.io/gpg | apt-key add -
19+
20+
# Add the Docker repository to your apt sources list.
21+
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
22+
23+
# upgrade to latest packages
24+
apt-get update
25+
apt-get dist-upgrade -yq
26+
27+
# install required packages
28+
apt-get install lxc-docker-0.7.6 fail2ban curl git inotify-tools make python-setuptools python-pip -yq
29+
30+
# wait for docker to start
31+
while [ ! -e /var/run/docker.sock ] ; do
32+
inotifywait -t 2 -e create $(dirname /var/run/docker.sock)
33+
done
34+
35+
# pull docker images
36+
docker pull deis/etcd
37+
docker pull deis/postgres
38+
docker pull deis/redis
39+
docker pull deis/server
40+
docker pull deis/worker
41+
docker pull deis/registry
42+
docker pull deis/builder
43+
docker pull deis/rsyslog
44+
45+
# install chef 11.x deps
46+
apt-get install -yq ruby1.9.1 ruby1.9.1-dev make
47+
update-alternatives --set ruby /usr/bin/ruby1.9.1
48+
update-alternatives --set gem /usr/bin/gem1.9.1
49+
50+
# clean and remove old packages
51+
apt-get clean
52+
apt-get autoremove -yq
53+
54+
# reset cloud-init
55+
rm -rf /var/lib/cloud
56+
57+
# purge SSH authorized keys
58+
rm -f /home/ubuntu/.ssh/authorized_keys
59+
rm -f /root/.ssh/authorized_keys
60+
61+
# remove /etc/chef so contents can't intefere with
62+
# node being converged (i.e. old keys)
63+
rm -f /etc/chef/*
64+
65+
# purge /var/log
66+
find /var/log -type f | xargs rm
67+
68+
# flush writes to block storage
69+
sync

contrib/digitalocean/prepare-digitalocean-snapshot.sh

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash -ex
2+
3+
#
4+
# Prepare a Deis-optimized Node image from a vanilla Ubuntu 12.04 droplet
5+
#
6+
# Instructions:
7+
#
8+
# 1. Launch a vanilla Ubuntu 12.04.3 droplet (64-bit)
9+
# 2. Run this script (as root!) to optimize the image for faster provisioning
10+
# 3. Create a new snapshot named "deis-node-base" from this droplet
11+
#
12+
13+
# Remove old kernel(s)
14+
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
15+
16+
# Add the Docker repository key to your local keychain
17+
# using apt-key finger you can check the fingerprint matches 36A1 D786 9245 C895 0F96 6E92 D857 6A8B A88D 21E9
18+
curl https://get.docker.io/gpg | apt-key add -
19+
20+
# Add the Docker repository to your apt sources list.
21+
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
22+
23+
# upgrade to latest packages
24+
apt-get update
25+
apt-get dist-upgrade -yq
26+
27+
# install required packages
28+
apt-get install lxc-docker-0.7.6 fail2ban curl git inotify-tools make python-setuptools python-pip -yq
29+
30+
# wait for docker to start
31+
while [ ! -e /var/run/docker.sock ] ; do
32+
inotifywait -t 2 -e create $(dirname /var/run/docker.sock)
33+
done
34+
35+
# pull docker images
36+
docker pull deis/slugrunner
37+
38+
# install chef 11.x deps
39+
apt-get install -yq ruby1.9.1 ruby1.9.1-dev make
40+
update-alternatives --set ruby /usr/bin/ruby1.9.1
41+
update-alternatives --set gem /usr/bin/gem1.9.1
42+
43+
# clean and remove old packages
44+
apt-get clean
45+
apt-get autoremove -yq
46+
47+
# reset cloud-init
48+
rm -rf /var/lib/cloud
49+
50+
# purge SSH authorized keys
51+
rm -f /home/ubuntu/.ssh/authorized_keys
52+
rm -f /root/.ssh/authorized_keys
53+
54+
# remove /etc/chef so contents can't intefere with
55+
# node being converged (i.e. old keys)
56+
rm -f /etc/chef/*
57+
58+
# purge /var/log
59+
find /var/log -type f | xargs rm
60+
61+
# flush writes to block storage
62+
sync

contrib/digitalocean/provision-digitalocean-controller.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ fi
5656

5757
# the name of the location we want to work with
5858
region_id=$1
59-
# The snapshot that we want to use (deis-base)
60-
image_id=$(knife digital_ocean image list | grep "deis-base" | awk '{print $1}')
61-
# the ID of the size (1GB)
59+
# The image that we want to use (deis-controller-base)
60+
image_id=$(knife digital_ocean image list | grep "deis-controller-base" | awk '{print $1}')
61+
# the ID of the size (2GB)
6262
size_id=$(knife digital_ocean size list | grep "2GB" | awk '{print $1}')
6363

6464
if [[ -z $image_id ]]; then
65-
echo "Can't find saved image \"deis-base\" in region $region_id. Please follow the"
65+
echo "Can't find saved image \"deis-controller-base\" in region $region_id. Please follow the"
6666
echo "instructions in prepare-digitalocean-snapshot.sh before provisioning a Deis controller."
6767
exit 1
6868
fi

provider/digitalocean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def seed_flavors():
2929
'params': json.dumps({
3030
'region': REGION_LIST[r],
3131
'size': '4GB',
32-
'image': 'deis-base'
32+
'image': 'deis-node-base'
3333
})
3434
})
3535
return flavors
@@ -89,7 +89,7 @@ def _get_droplet_kwargs(node, conn):
8989
return {
9090
'name': node['id'],
9191
'size_id': _get_id(conn.sizes(), params.get('size', '4GB')),
92-
'image_id': _get_id(conn.images(show_all=False), params.get('image', 'deis-base')),
92+
'image_id': _get_id(conn.images(show_all=False), params.get('image', 'deis-node-base')),
9393
'region_id': _get_id(conn.regions(), params.get('region', 'San Francisco 1')),
9494
'ssh_key_ids': [str(_get_id(conn.all_ssh_keys(),
9595
"deis-{formation}-{layer}".format(**node)))],

0 commit comments

Comments
 (0)