kubernetesamazon-eksnlbaws-nlbaws-load-balancer-controller

Targets not getting registered in AWS NLB target groups when creating a load balancer service in EKS


I'm creating a LoadBalancer service in EKS cluster using terraform. The service is getting created as well as the NLB is created too but the targets in the target groups are empty expect one target group. I have total 6 instances in the cluster.

I'm using the below code to create the Load Balancer service from terraform

resource "kubernetes_service" "ml" {
  count = (var.enabled_environments[var.namespace] == true && var.namespace != "prod" && var.namespace != "demo" ? 1 : 0)
  metadata {
    namespace = var.namespace
    name      = "${var.namespace}-xyz-ml-service"
    labels = {
      "app.kubernetes.io/component" = "${var.namespace}-xyz-ml"
    }
    annotations = {
      "service.beta.kubernetes.io/aws-load-balancer-type"                              = "nlb"
      "service.beta.kubernetes.io/aws-load-balancer-nlb-target-type"                   = "instance"
      "service.beta.kubernetes.io/aws-load-balancer-internal"                          = "true"
    }
  }
  spec {
    type = "LoadBalancer"
    port {
      name        = "abc-0"
      port        = 8110
      target_port = 8110
    }
    port {
      name        = "abc-1"
      port        = 8111
      target_port = 8111
    }
    port {
      name        = "abc-2"
      port        = 8112
      target_port = 8112
    }
    port {
      name        = "abc-3"
      port        = 8113
      target_port = 8113
    }
    selector = {
      app = "xyz-ml"
    }
  }
}

Can you let me know what am I missing here?

I tried following these steps https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html


Solution

  • The issue was because of limit for security group rules. So, that is why it was not registering targets. After increasing the security group rules limit it worked fine.