Skip to content

Commit 08d6d24

Browse files
author
Matthew Fisher
committed
fix(contrib/ec2): add custom template
While CoreOS's default template is great for setting up a cluster on CloudFormation, it's missing some custom security group rules that Deis needs. This custom template is a copy of CoreOS's template along with a few ports opened, which includes the ports that the Deis components live on as well as linux's default ephemeral port range, which docker relies on (as well as any Deis apps)
1 parent 78f05d4 commit 08d6d24

2 files changed

Lines changed: 149 additions & 1 deletion

File tree

contrib/ec2/deis.template

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "Deis on EC2: http://deis.io/",
4+
"Mappings" : {
5+
"RegionMap" : {
6+
"ap-northeast-1" : {
7+
"AMI" : "ami-85265f84"
8+
},
9+
"sa-east-1" : {
10+
"AMI" : "ami-9757f58a"
11+
},
12+
"ap-southeast-2" : {
13+
"AMI" : "ami-815fc7bb"
14+
},
15+
"ap-southeast-1" : {
16+
"AMI" : "ami-b80350ea"
17+
},
18+
"us-east-1" : {
19+
"AMI" : "ami-97617dfe"
20+
},
21+
"us-west-2" : {
22+
"AMI" : "ami-0ccfa43c"
23+
},
24+
"us-west-1" : {
25+
"AMI" : "ami-f8d3eabd"
26+
},
27+
"eu-west-1" : {
28+
"AMI" : "ami-dbdc27ac"
29+
}
30+
}
31+
},
32+
"Parameters": {
33+
"InstanceType" : {
34+
"Description" : "EC2 instance type (m1.small, etc).",
35+
"Type" : "String",
36+
"Default" : "t1.micro",
37+
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge", "m3.xlarge", "m3.2xlarge", "m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge", "hi1.4xlarge", "hs1.8xlarge"],
38+
"ConstraintDescription" : "must be a valid EC2 instance type."
39+
},
40+
"ClusterSize": {
41+
"Default": "3",
42+
"MinValue": "3",
43+
"MaxValue": "12",
44+
"Description": "Number of nodes in cluster (3-12).",
45+
"Type": "Number"
46+
},
47+
"DiscoveryURL": {
48+
"Description": "An unique etcd cluster discovery URL. Grab a new token from https://discovery.etcd.io/new",
49+
"Type": "String"
50+
},
51+
"AdvertisedIPAddress": {
52+
"Description": "Use 'private' if your etcd cluster is within one region or 'public' if it spans regions or cloud providers.",
53+
"Default": "private",
54+
"AllowedValues": ["private", "public"],
55+
"Type": "String"
56+
},
57+
"AllowSSHFrom": {
58+
"Description": "The net block (CIDR) that SSH is available to.",
59+
"Default": "0.0.0.0/0",
60+
"Type": "String"
61+
},
62+
"KeyPair" : {
63+
"Description" : "The name of an EC2 Key Pair to allow SSH access to the instance.",
64+
"Type" : "String"
65+
}
66+
},
67+
"Resources": {
68+
"CoreOSSecurityGroup": {
69+
"Type": "AWS::EC2::SecurityGroup",
70+
"Properties": {
71+
"GroupDescription": "CoreOS SecurityGroup",
72+
"SecurityGroupIngress": [
73+
{"IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": {"Ref": "AllowSSHFrom"}}
74+
]
75+
}
76+
},
77+
"DeisSecurityGroup": {
78+
"Type": "AWS::EC2::SecurityGroup",
79+
"Properties": {
80+
"GroupDescription": "Deis SecurityGroup",
81+
"SecurityGroupIngress": [
82+
{"IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "CidrIp": "0.0.0.0/0"},
83+
{"IpProtocol": "tcp", "FromPort": "514", "ToPort": "514", "CidrIp": "0.0.0.0/0"},
84+
{"IpProtocol": "tcp", "FromPort": "2222", "ToPort": "2222", "CidrIp": "0.0.0.0/0"},
85+
{"IpProtocol": "tcp", "FromPort": "5000", "ToPort": "5000", "CidrIp": "0.0.0.0/0"},
86+
{"IpProtocol": "tcp", "FromPort": "5432", "ToPort": "5432", "CidrIp": "0.0.0.0/0"},
87+
{"IpProtocol": "tcp", "FromPort": "6379", "ToPort": "6379", "CidrIp": "0.0.0.0/0"},
88+
{"IpProtocol": "tcp", "FromPort": "8000", "ToPort": "8000", "CidrIp": "0.0.0.0/0"},
89+
{"IpProtocol": "tcp", "FromPort": "49156", "ToPort": "65535", "CidrIp": "0.0.0.0/0"}
90+
]
91+
}
92+
},
93+
"Ingress4001": {
94+
"Type": "AWS::EC2::SecurityGroupIngress",
95+
"Properties": {
96+
"GroupName": {"Ref": "CoreOSSecurityGroup"}, "IpProtocol": "tcp", "FromPort": "4001", "ToPort": "4001", "SourceSecurityGroupId": {
97+
"Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ]
98+
}
99+
}
100+
},
101+
"Ingress7001": {
102+
"Type": "AWS::EC2::SecurityGroupIngress",
103+
"Properties": {
104+
"GroupName": {"Ref": "CoreOSSecurityGroup"}, "IpProtocol": "tcp", "FromPort": "7001", "ToPort": "7001", "SourceSecurityGroupId": {
105+
"Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ]
106+
}
107+
}
108+
},
109+
"CoreOSServerAutoScale": {
110+
"Type": "AWS::AutoScaling::AutoScalingGroup",
111+
"Properties": {
112+
"AvailabilityZones": {"Fn::GetAZs": ""},
113+
"LaunchConfigurationName": {"Ref": "CoreOSServerLaunchConfig"},
114+
"MinSize": "3",
115+
"MaxSize": "12",
116+
"DesiredCapacity": {"Ref": "ClusterSize"},
117+
"Tags": [
118+
{"Key": "Name", "Value": { "Ref" : "AWS::StackName" }, "PropagateAtLaunch": true}
119+
]
120+
}
121+
},
122+
"CoreOSServerLaunchConfig": {
123+
"Type": "AWS::AutoScaling::LaunchConfiguration",
124+
"Properties": {
125+
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
126+
"InstanceType": {"Ref": "InstanceType"},
127+
"KeyName": {"Ref": "KeyPair"},
128+
"SecurityGroups": [{"Ref": "CoreOSSecurityGroup"}, {"Ref": "DeisSecurityGroup"}],
129+
"UserData" : { "Fn::Base64":
130+
{ "Fn::Join": [ "", [
131+
"#cloud-config\n\n",
132+
"coreos:\n",
133+
" etcd:\n",
134+
" discovery: ", { "Ref": "DiscoveryURL" }, "\n",
135+
" addr: $", { "Ref": "AdvertisedIPAddress" }, "_ipv4:4001\n",
136+
" peer-addr: $", { "Ref": "AdvertisedIPAddress" }, "_ipv4:7001\n",
137+
" units:\n",
138+
" - name: etcd.service\n",
139+
" command: start\n",
140+
" - name: fleet.service\n",
141+
" command: start\n"
142+
] ]
143+
}
144+
}
145+
}
146+
}
147+
}
148+
}

contrib/ec2/provision-ec2-cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fi
1818

1919
# create an EC2 cloudformation stack based on CoreOS's default template
2020
aws cloudformation create-stack \
21-
--template-url https://s3.amazonaws.com/coreos.com/dist/aws/coreos-alpha.template \
21+
--template-body "$(<deis.template)" \
2222
--stack-name deis \
2323
--parameters "$(<cloudformation.json)"
2424

0 commit comments

Comments
 (0)