Skip to content

Commit 4173bef

Browse files
committed
fix: adding workking version with coredns on fargate
1 parent d87379b commit 4173bef

File tree

1 file changed

+45
-1
lines changed
  • terraform/environments/prod

1 file changed

+45
-1
lines changed

terraform/environments/prod/eks.tf

+45-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module "eks" {
7777
coredns = {
7878
most_recent = true
7979
configuration_values = jsonencode({
80-
computeType = "Fargate",
80+
computeType = "Fargate",
8181
replicaCount = 1,
8282
})
8383
}
@@ -113,8 +113,32 @@ module "eks" {
113113
}
114114
}
115115
fargate_profile_defaults = {
116+
create_iam_role = true # This is the Pod Exection role (https://docs.aws.amazon.com/eks/latest/userguide/pod-execution-role.html) used by fargate agent, not pod inside fargate
116117
iam_role_additional_policies = { CloudWatchAgentServerPolicy : "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy" }
118+
subnet_ids = module.vpc.private_subnets
117119
}
120+
121+
# # create_cluster_security_group = false
122+
# # create_node_security_group = false
123+
# cluster_security_group_additional_rules = {
124+
# ingress_dns_tcp = {
125+
# description = "Allow DNS TCP for CoreDNS running on Fargate"
126+
# protocol = "tcp"
127+
# from_port = 53
128+
# to_port = 53
129+
# type = "ingress"
130+
# source_node_security_group = true
131+
# },
132+
# ingress_dns_udp = {
133+
# description = "Allow DNS UDP for CoreDNS running on Fargate"
134+
# protocol = "udp"
135+
# from_port = 53
136+
# to_port = 53
137+
# type = "ingress"
138+
# source_node_security_group = true
139+
# }
140+
# }
141+
118142
node_security_group_tags = merge(local.tags, {
119143
# NOTE - if creating multiple security groups with this module, only tag the
120144
# security group that Karpenter should utilize with the following tag
@@ -124,6 +148,26 @@ module "eks" {
124148
tags = local.tags
125149
}
126150

151+
## CoreDNS is running on Fargate. Fargate by defualt uses the eks cluster primary security group.
152+
resource "aws_security_group_rule" "ingress_dns_tcp" {
153+
security_group_id = module.eks.cluster_primary_security_group_id
154+
description = "Allow DNS TCP for CoreDNS running on Fargate"
155+
protocol = "tcp"
156+
from_port = 53
157+
to_port = 53
158+
type = "ingress"
159+
source_security_group_id = module.eks.node_security_group_id
160+
}
161+
162+
resource "aws_security_group_rule" "ingress_dns_udp" {
163+
security_group_id = module.eks.cluster_primary_security_group_id
164+
description = "Allow DNS UDP for CoreDNS running on Fargate"
165+
protocol = "udp"
166+
from_port = 53
167+
to_port = 53
168+
type = "ingress"
169+
source_security_group_id = module.eks.node_security_group_id
170+
}
127171
################################################################################
128172
# Karpenter
129173
################################################################################

0 commit comments

Comments
 (0)