-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathspot-node-group.yaml
165 lines (165 loc) · 7.73 KB
/
spot-node-group.yaml
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
AWSTemplateFormatVersion: 2010-09-09
Description: 'EKS nodes (Amazon Linux 2 with SSH) [created and managed by eksctl]'
Parameters:
ClusterName:
Type: String
ClusterStackName:
Type: String
NodeGroupID:
Type: Number
Resources:
EgressInterCluster:
Type: 'AWS::EC2::SecurityGroupEgress'
Properties:
Description: !Sub >-
Allow worker nodes in group ${ClusterName}-${NodeGroupID} to communicate
with control plane (kubelet and workload TCP ports)
DestinationSecurityGroupId: !Ref SG
FromPort: 1025
GroupId: !ImportValue
'Fn::Sub': '${ClusterStackName}::SecurityGroup'
IpProtocol: tcp
ToPort: 65535
IngressInterCluster:
Type: 'AWS::EC2::SecurityGroupIngress'
Properties:
Description: !Sub >-
Allow worker nodes in group ${ClusterName}-${NodeGroupID} to communicate
with control plane (kubelet and workload TCP ports)
FromPort: 1025
GroupId: !Ref SG
IpProtocol: tcp
SourceSecurityGroupId: !ImportValue
'Fn::Sub': '${ClusterStackName}::SecurityGroup'
ToPort: 65535
IngressInterClusterCP:
Type: 'AWS::EC2::SecurityGroupIngress'
Properties:
Description: !Sub >-
Allow control plane to recieve API requests from worker nodes in group
${ClusterName}-${NodeGroupID}
FromPort: 443
GroupId: !ImportValue
'Fn::Sub': '${ClusterStackName}::SecurityGroup'
IpProtocol: tcp
SourceSecurityGroupId: !Ref SG
ToPort: 443
IngressInterSG:
Type: 'AWS::EC2::SecurityGroupIngress'
Properties:
Description: !Sub >-
Allow worker nodes in group ${ClusterName}-${NodeGroupID} to communicate
with each other (all ports)
GroupId: !Ref SG
IpProtocol: '-1'
SourceSecurityGroupId: !Ref SG
ToPort: 65535
NodeGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
Properties:
DesiredCapacity: '2'
LaunchConfigurationName: !Ref NodeLaunchConfig
MaxSize: '4'
MinSize: '2'
Tags:
- Key: Name
PropagateAtLaunch: 'true'
Value: !Sub '${ClusterName}-${NodeGroupID}-Node'
- Key: !Sub 'kubernetes.io/cluster/${ClusterName}'
PropagateAtLaunch: 'true'
Value: owned
VPCZoneIdentifier: !Split
- ','
- !ImportValue
'Fn::Sub': '${ClusterStackName}::Subnets'
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: '1'
MinInstancesInService: '1'
NodeInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref NodeInstanceRole
NodeInstanceRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- 'sts:AssumeRole'
Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Version: 2012-10-17
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy'
- 'arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy'
- 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser'
Path: /
NodeLaunchConfig:
Type: 'AWS::AutoScaling::LaunchConfiguration'
Properties:
AssociatePublicIpAddress: true
IamInstanceProfile: !Ref NodeInstanceProfile
ImageId: ami-08cab282f9979fc7a
InstanceType: m5.large
SecurityGroups:
- !Ref SG
UserData: >-
H4sIAAAAAAAA/6RY727bOBL/7qeYUwOkwYVSnE3aXQPaQ65Ji6DZpGja3QPWRUKLY5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VCXU2MCrcPFYM4bUSZqjl0gHpANJuBcoWigj0C+g5mCGStH/NtpcuG5Jv0kWwFV3s6GxOa/QVrm95khr+1kE8PMT96LKYN3/0zoeIdh30YryAzMJ3U4IUi+34KZmYcLkfcg1HA0LvH51Ri+9b0AZPY3KaFVogctWWg/vqiK6Wzhbo+2C0NZyGurUb8YBuV/gFhwqzPzL+D1eQ5pC9B0wjrbgFiokb7YdyMaYTeYuUCMSSz54PkqjxUWF7NfCycZNtz5M4yzjdhTaQbRx4/noLnrc/w3PRw+4RQkiWDTJbAq/Has2bEgmwGU1oI0iUQSsU1gTAFpv27iLtiJIIQqLUWel8Ffv6OmqMsDPj1T9Y93///js9OQ1//avTzT+2nlo3fBDr3vwG8lM+vHy9f5PN+cKQU9RxYMk2Fp9//nvR2/OTt8ev0ujR2bBOqsNQTT1sMohE7fgkCZOz6ERKoRHv+ks8FhZbRrgqkPzBqBFYaT2bQy0VNudo2GHRmVrqYIfUtuc67W+kBw0H0hiysQm3FIPwVd7wMQKN9ej7fyDxeLzGeV7HrsFsVCXr+on2rhpXL0Lrv5pfKx8Xl0Pkf8FAAD//0HsKKY6FgAA
PolicyStackSignal:
Type: 'AWS::IAM::Policy'
Properties:
PolicyDocument:
Statement:
- Action:
- 'cloudformation:SignalResource'
Effect: Allow
Resource: !Join
- ':'
- - 'arn:aws:cloudformation'
- !Ref 'AWS::Region'
- !Ref 'AWS::AccountId'
- !Join
- /
- - stack
- !Ref 'AWS::StackName'
- '*'
Version: 2012-10-17
PolicyName: !Sub '${AWS::StackName}-PolicyStackSignal'
Roles:
- !Ref NodeInstanceRole
PolicyTagDiscovery:
Type: 'AWS::IAM::Policy'
Properties:
PolicyDocument:
Statement:
- Action:
- 'ec2:DescribeTags'
Effect: Allow
Resource: '*'
Version: 2012-10-17
PolicyName: !Sub '${AWS::StackName}-PolicyTagDiscovery'
Roles:
- !Ref NodeInstanceRole
SG:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: !Sub >-
Communication between the control plane and worker nodes in group
${ClusterName}-${NodeGroupID}
Tags:
- Key: !Sub 'kubernetes.io/cluster/${ClusterName}'
Value: owned
- Key: Name
Value: !Sub '${AWS::StackName}/SG'
VpcId: !ImportValue
'Fn::Sub': '${ClusterStackName}::VPC'
Outputs:
NodeInstanceRoleARN:
Export:
Name: !Sub '${AWS::StackName}::NodeInstanceRoleARN'
Value: !GetAtt NodeInstanceRole.Arn