-
Notifications
You must be signed in to change notification settings - Fork 44
/
eks.tf
90 lines (69 loc) · 1.94 KB
/
eks.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
84
85
86
87
88
89
90
resource "aws_eks_cluster" "main" {
name = var.cluster_name
version = var.k8s_version
role_arn = aws_iam_role.eks_cluster_role.arn
vpc_config {
security_group_ids = [
aws_security_group.cluster_sg.id,
aws_security_group.cluster_nodes_sg.id
]
subnet_ids = [
aws_subnet.private_subnet_1a.id,
aws_subnet.private_subnet_1b.id,
aws_subnet.private_subnet_1c.id
]
}
encryption_config {
provider {
key_arn = aws_kms_key.eks.arn
}
resources = ["secrets"]
}
enabled_cluster_log_types = [
"api", "audit", "authenticator", "controllerManager", "scheduler"
]
tags = {
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
"k8s.io/cluster-autoscaler/${var.cluster_name}" = "owned",
"k8s.io/cluster-autoscaler/enabled" = true
}
}
resource "aws_security_group" "cluster_sg" {
name = format("%s-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-sg", var.cluster_name)
}
}
resource "aws_security_group_rule" "cluster_ingress_https" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 443
to_port = 443
protocol = "tcp"
security_group_id = aws_security_group.cluster_sg.id
type = "ingress"
}
resource "aws_security_group_rule" "nodeport_cluster" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 30000
to_port = 32768
description = "nodeport"
protocol = "tcp"
security_group_id = aws_eks_cluster.main.vpc_config[0].cluster_security_group_id
type = "ingress"
}
resource "aws_security_group_rule" "nodeport_cluster_udp" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 30000
to_port = 32768
description = "nodeport"
protocol = "udp"
security_group_id = aws_eks_cluster.main.vpc_config[0].cluster_security_group_id
type = "ingress"
}