-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
150 lines (125 loc) · 3.46 KB
/
main.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
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
provider "aws" {
region = local.region
}
locals {
name = "jobs"
region = "eu-south-2"
vpc_cidr = "10.123.0.0/16"
azs = ["eu-south-2a", "eu-south-2b"]
public_subnets = ["10.123.1.0/24", "10.123.2.0/24"]
private_subnets = ["10.123.3.0/24", "10.123.4.0/24"]
intra_subnets = ["10.123.5.0/24", "10.123.6.0/24"]
tags = {
Example = local.name
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.8.1"
name = local.name
cidr = local.vpc_cidr
azs = local.azs
private_subnets = local.private_subnets
public_subnets = local.public_subnets
intra_subnets = local.intra_subnets
enable_nat_gateway = true
enable_vpn_gateway = true
public_subnet_tags = {
"kubernetes.io/role/elb" = 1
}
private_subnet_tags = {
"kubernetes.io/role/internal-elb" = 1
}
tags = {
Terraform = "true"
Environment = "dev"
}
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "20.11.0"
cluster_name = local.name
cluster_version = "1.29"
cluster_endpoint_public_access = true
cluster_addons = {
coredns = {
most_recent = true
}
kube-proxy = {
most_recent = true
}
vpc-cni = {
most_recent = true
}
aws-ebs-csi-driver = {
most_recent = true
}
}
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
control_plane_subnet_ids = module.vpc.intra_subnets
# EKS Managed Node Group(s)
eks_managed_node_group_defaults = {
instance_types = ["m7a.xlarge"]
}
eks_managed_node_groups = {
jobs = {
min_size = 3
max_size = 3
desired_size = 3
instance_types = ["m7a.xlarge"]
capacity_type = "SPOT"
iam_role_additional_policies = {
policies = "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy" # IAM rights needed by CSI driver
}
}
}
# Extend node-to-node security group rules
node_security_group_additional_rules = {
ingress_self_all = {
description = "Node to node all ports/protocols"
protocol = "-1"
from_port = 0
to_port = 0
type = "ingress"
self = true
}
egress_all = {
description = "Node all egress"
protocol = "-1"
from_port = 0
to_port = 0
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
// Kubeseal access
ingress_cluster_api_ephemeral_ports_tcp = {
description = "Cluster API to K8S services running on nodes"
protocol = "tcp"
from_port = 1025
to_port = 65535
type = "ingress"
source_cluster_security_group = true
}
}
// Kubeseal access
cluster_security_group_additional_rules = {
egress_nodes_ephemeral_ports_tcp = {
description = "Cluster API to K8S services running on nodes"
protocol = "tcp"
from_port = 1025
to_port = 65535
type = "egress"
source_node_security_group = true
}
// your other rules go here
}
# Cluster access entry
# To add the current caller identity as an administrator
enable_cluster_creator_admin_permissions = true
tags = {
Environment = "dev"
Terraform = "true"
}
}