-
Notifications
You must be signed in to change notification settings - Fork 45
/
nodes.tf
75 lines (59 loc) · 1.6 KB
/
nodes.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
resource "aws_eks_node_group" "main" {
cluster_name = aws_eks_cluster.main.name
node_group_name = format("%s-node-group", aws_eks_cluster.main.name)
node_role_arn = aws_iam_role.eks_nodes_roles.arn
subnet_ids = [
aws_subnet.private_subnet_1a.id,
aws_subnet.private_subnet_1b.id,
aws_subnet.private_subnet_1c.id
]
instance_types = var.nodes_instances_sizes
scaling_config {
desired_size = lookup(var.auto_scale_options, "desired")
max_size = lookup(var.auto_scale_options, "max")
min_size = lookup(var.auto_scale_options, "min")
}
labels = {
"ingress/ready" = "true"
}
tags = {
"kubernetes.io/cluster/${var.cluster_name}" = "owned",
"k8s.io/cluster-autoscaler/${var.cluster_name}" = "owned",
"k8s.io/cluster-autoscaler/enabled" = true
}
lifecycle {
ignore_changes = [
scaling_config[0].desired_size
]
}
depends_on = [
kubernetes_config_map.aws-auth
]
timeouts {
create = "60m"
update = "2h"
delete = "2h"
}
}
resource "aws_security_group" "cluster_nodes_sg" {
name = format("%s-nodes-sg", var.cluster_name)
vpc_id = aws_vpc.cluster_vpc.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = format("%s-nodes-sg", var.cluster_name)
}
}
resource "aws_security_group_rule" "nodeport" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 30000
to_port = 32768
description = "nodeport"
protocol = "tcp"
security_group_id = aws_security_group.cluster_nodes_sg.id
type = "ingress"
}