<p>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.</p>
<p>I'm using the below code to create the Load Balancer service from terraform</p>
<pre><code>resource &quot;kubernetes_service&quot; &quot;ml&quot; {
  count = (var.enabled_environments[var.namespace] == true &amp;&amp; var.namespace != &quot;prod&quot; &amp;&amp; var.namespace != &quot;demo&quot; ? 1 : 0)
  metadata {
    namespace = var.namespace
    name      = &quot;${var.namespace}-xyz-ml-service&quot;
    labels = {
      &quot;app.kubernetes.io/component&quot; = &quot;${var.namespace}-xyz-ml&quot;
    }
    annotations = {
      &quot;service.beta.kubernetes.io/aws-load-balancer-type&quot;                              = &quot;nlb&quot;
      &quot;service.beta.kubernetes.io/aws-load-balancer-nlb-target-type&quot;                   = &quot;instance&quot;
      &quot;service.beta.kubernetes.io/aws-load-balancer-internal&quot;                          = &quot;true&quot;
    }
  }
  spec {
    type = &quot;LoadBalancer&quot;
    port {
      name        = &quot;abc-0&quot;
      port        = 8110
      target_port = 8110
    }
    port {
      name        = &quot;abc-1&quot;
      port        = 8111
      target_port = 8111
    }
    port {
      name        = &quot;abc-2&quot;
      port        = 8112
      target_port = 8112
    }
    port {
      name        = &quot;abc-3&quot;
      port        = 8113
      target_port = 8113
    }
    selector = {
      app = &quot;xyz-ml&quot;
    }
  }
}
</code></pre>
<p>Can you let me know what am I missing here?</p>
<p>I tried following these steps
<a href="https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html</a></p>

vishal mehra
<p>Here are a few things to check:</p>
<ol>
<li><p>Check your pod's selector. Based on TF code, your service will forward requests to pods with the label &quot;app&quot;=&quot;xyz-ml&quot;. Double-check to ensure that your pods have this label.</p>
</li>
<li><p>Are your pods running? To be targeted by a service, pods must be running and healthy. Check this using the <code>kubectl get pods -n &lt;namespace&gt;</code></p>
</li>
<li><p>Ensure that your pods are listening on these ports: 8110, 8111, 8112, and 8113.</p>
</li>
<li><p>If your nodes are not in the correct subnet for the load balancer, they will not be registered as targets.</p>
</li>
<li><p>Ensure your pods and services are in the same namespace.</p>
</li>
<li><p>Verify that your Network ACLs and Security Groups are not blocking in/out traffic.</p>
</li>
</ol>
