-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheks-node-groups.tf
83 lines (68 loc) · 2.34 KB
/
eks-node-groups.tf
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
resource "aws_iam_role" "nodes_general" {
name = "eks-node-group-general"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "ec2.amazonaws.com"
}
},
]
})
}
resource "aws_iam_role_policy_attachment" "amazon_eks_worker_node_policy_general" {
role = aws_iam_role.nodes_general.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
}
resource "aws_iam_role_policy_attachment" "amazon_eks_cni_policy_general" {
role = aws_iam_role.nodes_general.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
}
resource "aws_iam_role_policy_attachment" "amazon_ec2_container_registry_read_only" {
role = aws_iam_role.nodes_general.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
}
# resource "aws_iam_role_policy_attachment" "aws_loadbalancer_controller_iam" {
# role = aws_iam_role.nodes_general.name
# policy_arn = aws_iam_policy.aws_loadbalancer_controller_policy.arn
# }
resource "aws_eks_node_group" "nodes_general" {
cluster_name = aws_eks_cluster.eks.name
node_group_name = "nodes-general"
node_role_arn = aws_iam_role.nodes_general.arn
subnet_ids = [
aws_subnet.private_1.id,
aws_subnet.private_2.id
]
scaling_config {
desired_size = 2
max_size = 3
min_size = 2
}
ami_type = "AL2_x86_64"
capacity_type = "ON_DEMAND"
disk_size = 20
force_update_version = false
#Important because instance type affect max pods pr
instance_types = ["t3.small"]
labels = {
role = "nodes_general"
}
update_config {
max_unavailable = 1
}
# Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
# Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
depends_on = [
aws_iam_role_policy_attachment.amazon_eks_worker_node_policy_general,
aws_iam_role_policy_attachment.amazon_eks_cni_policy_general,
aws_iam_role_policy_attachment.amazon_ec2_container_registry_read_only,
# aws_iam_role_policy_attachment.aws_loadbalancer_controller_iam,
]
}