Skip to content

Commit e5182be

Browse files
committed
Merge pull request #2803 from carmstrong/ec2-docker_volume
feat(contrib/ec2): use separate volume for /var/lib/docker
2 parents 35b8ae8 + 6db1e50 commit e5182be

4 files changed

Lines changed: 48 additions & 10 deletions

File tree

contrib/ec2/deis.template.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@
251251
"BlockDeviceMappings" : [
252252
{
253253
"DeviceName" : { "Fn::FindInMap": [ "RootDevices", { "Ref": "EC2VirtualizationType" }, "Name" ] },
254+
"Ebs" : { "VolumeSize" : "50" }
255+
},
256+
{
257+
"DeviceName" : "/dev/xvdf",
254258
"Ebs" : { "VolumeSize" : "100" }
255259
}
256260
]

contrib/ec2/gen-json.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
11
#!/usr/bin/env python
22
import json
33
import os
4+
import yaml
45

5-
template = json.load(open("deis.template.json",'r'))
6+
CURR_DIR = os.path.dirname(os.path.realpath(__file__))
67

7-
with open('../coreos/user-data','r') as f:
8-
lines = f.readlines()
8+
# Add EC2-specific units to the shared user-data
9+
FORMAT_EPHEMERAL = '''
10+
[Unit]
11+
Description=Formats the ephemeral drive
12+
ConditionPathExists=!/etc/docker-volume-formatted
13+
[Service]
14+
Type=oneshot
15+
RemainAfterExit=yes
16+
ExecStart=/usr/sbin/wipefs -f /dev/xvdf
17+
ExecStart=/usr/sbin/mkfs.btrfs -f /dev/xvdf
18+
ExecStart=/bin/touch /etc/docker-volume-formatted
19+
'''
20+
DOCKER_MOUNT = '''
21+
[Unit]
22+
Description=Mount ephemeral to /var/lib/docker
23+
Requires=format-ephemeral.service
24+
After=format-ephemeral.service
25+
Before=docker.service
26+
[Mount]
27+
What=/dev/xvdf
28+
Where=/var/lib/docker
29+
Type=btrfs
30+
'''
931

10-
template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = [ '', lines ]
32+
data = yaml.load(file(os.path.join(CURR_DIR, '..', 'coreos', 'user-data'), 'r'))
33+
data['coreos']['units'].append(dict({'name': 'format-ephemeral.service', 'command': 'start', 'content': FORMAT_EPHEMERAL}))
34+
data['coreos']['units'].append(dict({'name': 'var-lib-docker.mount', 'command': 'start', 'content': DOCKER_MOUNT}))
35+
36+
header = ["#cloud-config", "---"]
37+
dump = yaml.dump(data, default_flow_style=False)
38+
39+
template = json.load(open(os.path.join(CURR_DIR, 'deis.template.json'),'r'))
40+
41+
template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = [ "\n", header + dump.split("\n") ]
1142
template['Parameters']['ClusterSize']['Default'] = str(os.getenv('DEIS_NUM_INSTANCES', 3))
1243

1344
VPC_ID = os.getenv('VPC_ID', None)

contrib/ec2/provision-ec2-cluster.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ $CONTRIB_DIR/util/check-user-data.sh
4040

4141
# create an EC2 cloudformation stack based on CoreOS's default template
4242
aws cloudformation create-stack \
43-
--template-body "$(./gen-json.py)" \
43+
--template-body "$($THIS_DIR/gen-json.py)" \
4444
--stack-name $NAME \
45-
--parameters "$(<cloudformation.json)"
45+
--parameters "$(<$THIS_DIR/cloudformation.json)"
4646

4747
echo_green "Your Deis cluster has successfully deployed to AWS CloudFormation."
4848
echo_green "Please continue to follow the instructions in the README."

docs/installing_deis/aws.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ In order to start working with Amazon's API, let's install `awscli`_:
2020
.. code-block:: console
2121
2222
$ pip install awscli
23-
Downloading/unpacking awscli
24-
Downloading awscli-1.5.0.tar.gz (248kB): 248kB downloaded
25-
...
26-
Successfully installed awscli
23+
24+
We'll also need `PyYAML`_ for the Deis EC2 provision script to run:
25+
26+
.. code-block:: console
27+
28+
$ pip install pyyaml
2729
2830
2931
Configure aws-cli
@@ -177,3 +179,4 @@ start installing the platform.
177179
.. _`cloudformation.json`: https://github.com/deis/deis/blob/master/contrib/ec2/cloudformation.json
178180
.. _`etcd`: https://github.com/coreos/etcd
179181
.. _`optimal etcd cluster size`: https://github.com/coreos/etcd/blob/master/Documentation/optimal-cluster-size.md
182+
.. _`PyYAML`: http://pyyaml.org/

0 commit comments

Comments
 (0)