Skip to content

Commit

Permalink
update ALB to use IngressClass
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Eliot committed Feb 3, 2025
1 parent 9971a1a commit 46b2e71
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions terraform/modules/lbc-alb/lbc-alb.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@

# Note, do set "kubernetes.io/ingress.class" = "alb" in Ingress. That is deprecated.
# https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/ingress/ingress_class/#deprecated-kubernetesioingressclass-annotation
# Instead specify an IngressClass to use.

# This is the IngressClass created when Helm installed the AWS LBC
locals {
ingress_class_name = "alb"
}

# Kubernetes Ingress Resource for ALB via AWS Load Balancer Controller
resource "kubernetes_ingress_v1" "xyz_ingress_alb" {
metadata {
name = "xyz-ingress-alb-${var.env_name}"
namespace = "default"
annotations = {
"kubernetes.io/ingress.class" = "alb"
"alb.ingress.kubernetes.io/scheme" = "internet-facing"
"alb.ingress.kubernetes.io/target-type" = "ip"
"alb.ingress.kubernetes.io/listen-ports" = "[{\"HTTP\": 80}]"
"alb.ingress.kubernetes.io/load-balancer-attributes" = "idle_timeout.timeout_seconds=60"
# "alb.ingress.kubernetes.io/subnets" = var.public_subnets
"alb.ingress.kubernetes.io/tags" = "Terraform=true,Environment=${var.env_name}"
"alb.ingress.kubernetes.io/tags" = "Terraform=true,Environment=${var.env_name}"
}
}

spec {
ingress_class_name = local.ingress_class_name

rule {
http {
path {
Expand Down Expand Up @@ -58,4 +68,3 @@ resource "kubernetes_service_v1" "xyz_service_alb" {
type = "ClusterIP"
}
}

0 comments on commit 46b2e71

Please sign in to comment.