-
Notifications
You must be signed in to change notification settings - Fork 4
/
aws-eks-nodes.yaml
128 lines (122 loc) · 3.39 KB
/
aws-eks-nodes.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
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
ClusterName:
Type: String
Default: "demo4"
NodeInstanceRoleName:
Type: String
Default: "EksNodeRole"
NodeGroupName:
Type: String
Default: "demo4-ng1"
NodeImageId:
Type: AWS::EC2::Image::Id
Default: "ami-098fb7e9b507904e7"
NodeInstanceType:
Type: String
Default: "t3.medium"
NodeKeyName:
Type: AWS::EC2::KeyPair::KeyName
Default: "test-aws3-ireland"
NodeSecurityGroup:
Type: String
Default: "sg-e0b51a91"
NodeVolumeSize:
Type: Number
Default: 20
NodeVolumeType:
Type: String
Default: "gp2"
NodeAutoScalingGroupDesiredCapacity:
Type: Number
Default: 2
NodeAutoScalingGroupMinSize:
Type: Number
Default: 1
NodeAutoScalingGroupMaxSize:
Type: Number
Default: 4
NodeSubnet1:
Type: String
Default: "subnet-3c1bbc66"
NodeSubnet2:
Type: String
Default: "subnet-46bbde20"
NodeBootstrapArguments:
Default: ""
Type: String
Resources:
NodeInstanceRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
- "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
- "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
RoleName: !Ref NodeInstanceRoleName
NodeInstanceProfile:
Type: "AWS::IAM::InstanceProfile"
Properties:
Path: "/"
Roles:
- !Ref NodeInstanceRole
NodeLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
AssociatePublicIpAddress: "true"
IamInstanceProfile: !Ref NodeInstanceProfile
ImageId: !Ref NodeImageId
InstanceType: !Ref NodeInstanceType
KeyName: !Ref NodeKeyName
SecurityGroups:
- !Ref NodeSecurityGroup
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
VolumeSize: !Ref NodeVolumeSize
VolumeType: !Ref NodeVolumeType
DeleteOnTermination: "true"
UserData:
Fn::Base64:
!Sub |
#!/bin/bash
set -o xtrace
/etc/eks/bootstrap.sh ${ClusterName} ${NodeBootstrapArguments}
/opt/aws/bin/cfn-signal --exit-code $? \
--stack ${AWS::StackName} \
--resource NodeGroup \
--region ${AWS::Region}
NodeGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
Properties:
DesiredCapacity: !Ref NodeAutoScalingGroupDesiredCapacity
LaunchConfigurationName: !Ref NodeLaunchConfig
MinSize: !Ref NodeAutoScalingGroupMinSize
MaxSize: !Ref NodeAutoScalingGroupMaxSize
VPCZoneIdentifier:
- !Ref NodeSubnet1
- !Ref NodeSubnet2
Tags:
- Key: Name
Value: !Sub "${ClusterName}-${NodeGroupName}-Node"
PropagateAtLaunch: 'true'
- Key: !Sub 'kubernetes.io/cluster/${ClusterName}'
Value: "owned"
PropagateAtLaunch: "true"
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: "1"
MinInstancesInService: !Ref NodeAutoScalingGroupDesiredCapacity
PauseTime: "PT5M"
Outputs:
NodeInstanceRole:
Value: !GetAtt NodeInstanceRole.Arn