Skip to content

Commit e301507

Browse files
authored
Merge pull request #45 from datafold/gerard-p-3645-poc-vertical-pod-autoscaling-vpa
fix: Fix LB IP collector and VPA adm. controller
2 parents 80bb277 + 084ac30 commit e301507

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

modules/eks/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ resource "aws_security_group_rule" "lb_ingress" {
154154
]
155155
}
156156

157+
resource "aws_security_group_rule" "vpa_ingress" {
158+
type = "ingress"
159+
from_port = var.vpa_port
160+
to_port = var.vpa_port
161+
protocol = "tcp"
162+
source_security_group_id = module.eks.cluster_security_group_id
163+
security_group_id = module.eks.node_security_group_id
164+
description = "Allows traffic from cluster control plane to VPA admission controller"
165+
166+
depends_on = [
167+
module.eks
168+
]
169+
}
170+
157171
resource "aws_security_group_rule" "db_ingress" {
158172
type = "ingress"
159173
from_port = var.rds_port

modules/eks/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ variable "backend_app_port" {
8383
description = "The target port to use for the backend services"
8484
}
8585

86+
variable "vpa_port" {
87+
type = number
88+
default = 8000
89+
description = "The port for the VPA admission controller"
90+
}
91+
8692
variable "rds_port" {
8793
type = number
8894
default = 5432

modules/load_balancer/main.tf

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,20 @@ locals {
109109
vpc_subnets_joined = join(",", var.vpc_subnets)
110110
}
111111

112-
data "aws_network_interface" "lb_app" {
113-
count = length(var.vpc_subnets)
114-
112+
data "aws_network_interfaces" "lb_app" {
115113
filter {
116114
name = "description"
117115
values = ["ELB ${module.alb_app.lb_arn_suffix}"]
118116
}
119117

120-
filter {
121-
name = "subnet-id"
122-
values = [split(",", local.vpc_subnets_joined)[count.index]]
123-
}
124-
125118
depends_on = [ module.alb_app ]
126119
}
127120

121+
data "aws_network_interface" "lb_app" {
122+
for_each = toset(data.aws_network_interfaces.lb_app.ids)
123+
id = each.value
124+
}
125+
128126
locals {
129127
lb_ips = var.lb_internal ? jsonencode([for eni in data.aws_network_interface.lb_app : format("%s", eni.private_ip)]) : jsonencode([for eni in data.aws_network_interface.lb_app : format("%s", eni.association[0].public_ip)])
130128
}

0 commit comments

Comments
 (0)