-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2k8s.json
148 lines (146 loc) · 5.04 KB
/
ec2k8s.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description":"Creates three EC2 Ubuntu 20.04 instances for k8s (1 primary, 2 worker) ",
"Resources": {
"NewKeyPair": {
"Type": "AWS::EC2::KeyPair",
"Properties": {
"KeyName":"MyKeyPair",
"KeyType":"ed25519",
"Tags" : [ {"Key":"system", "Value":"k8s"}]
}
},
"Primary": {
"Type": "AWS::EC2::Instance",
"Properties": {
"SecurityGroups": [
{
"Ref": "InstanceSecurityGroup"
}
],
"KeyName": {"Ref": "NewKeyPair"},
"InstanceType": "m5a.large",
"ImageId": "ami-0ddf424f81ddb0720",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {"VolumeSize": 20}
}
],
"Tags": [
{"Key": "Name", "Value": "Primary"},
{"Key": "system", "Value": "k8s"}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": ["", [
"#!/bin/bash\n",
"sudo hostname primary \n",
"echo primary > /etc/hostname\n",
"sudo apt update && sudo apt upgrade -y"
]]
}
}
}
},
"Worker1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"SecurityGroups": [
{
"Ref": "InstanceSecurityGroup"
}
],
"KeyName": {"Ref": "NewKeyPair"},
"InstanceType": "m5a.large",
"ImageId": "ami-0ddf424f81ddb0720",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {"VolumeSize": 20}
}
],
"Tags": [
{"Key": "Name", "Value": "Worker1"},
{"Key": "system", "Value": "k8s"}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": ["", [
"#!/bin/bash\n",
"sudo hostname worker1 \n",
"echo worker1 > /etc/hostname\n"
"sudo apt update && sudo apt upgrade -y"
]]
}
}
}
},
"Worker2": {
"Type": "AWS::EC2::Instance",
"Properties": {
"SecurityGroups": [
{
"Ref": "InstanceSecurityGroup"
}
],
"KeyName": {"Ref": "NewKeyPair"},
"InstanceType": "m5a.large",
"ImageId": "ami-0ddf424f81ddb0720",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {"VolumeSize": 20}
}
],
"Tags": [
{"Key": "Name", "Value": "Worker2"},
{"Key": "system", "Value": "k8s"}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": ["", [
"#!/bin/bash\n",
"sudo hostname worker2 \n",
"echo worker2 > /etc/hostname\n"
"sudo apt update && sudo apt upgrade -y"
]]
}
}
}
},
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow ssh, 6443, icmp ingress, k8s service port range",
"Tags":[{"Key": "system", "Value": "k8s"}],
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": 22,
"ToPort": 22,
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": 6443,
"ToPort": 6443,
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "icmp",
"FromPort": -1,
"ToPort": -1,
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort": 30000,
"ToPort" : 32767,
"CidrIp" : "0.0.0.0/0"
}
]
}
}
}
}