<p>I want to expose a tcp-only service from my Fargate cluster to the public internet on port 80. To achieve this I want to use an AWS Network Load Balancer</p>
<p>This is the configuration of my service:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: myapp
  labels:
    app: myapp
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb&quot;
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
    service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: &quot;30&quot;
spec:
  type: LoadBalancer
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
</code></pre>
<p>Using the service from inside the cluster with CLUSTER-IP works. When I apply my config with kubectl the following happens:</p>
<ul>
<li>Service is created in K8s</li>
<li>NLB is created in AWS</li>
<li>NLB gets Status 'active'</li>
<li>VPC and other values for the NLB look correct</li>
<li>Target Group is created in AWS</li>
<li>There are 0 targets registered</li>
<li>I can't register targets because group expects instances, which I do not have</li>
<li>EXTERNAL_IP is </li>
<li>Listener is not created automatically</li>
</ul>
<p>Then I create a listener for Port 80 and TCP. After some wait an EXTERNAL_IP is assigned to the service in AWS.</p>
<p>My Problem: It does not work. The service is not available using the DNS Name from the NLB and Port 80.</p>

Daniel Müller
<p>The <em>in-tree</em> Kubernetes <code>Service</code> LoadBalancer for AWS, can not be used for AWS Fargate.</p>
<blockquote>
<p>You can use NLB instance targets with pods deployed to nodes, but not to Fargate.</p>
</blockquote>
<p>But you can now install <a href="https://github.com/kubernetes-sigs/aws-load-balancer-controller" rel="nofollow noreferrer">AWS Load Balancer Controller</a> and use <strong>IP Mode</strong> on your <code>Service</code> LoadBalancer, this also works for AWS Fargate.</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: nlb-ip-svc
  annotations:
    # route traffic directly to pod IPs
    service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb-ip&quot;
</code></pre>
<p>See <a href="https://aws.amazon.com/blogs/containers/introducing-aws-load-balancer-controller/" rel="nofollow noreferrer">Introducing AWS Load Balancer Controller</a> and <a href="https://docs.aws.amazon.com/eks/latest/userguide/load-balancing.html#load-balancer-ip" rel="nofollow noreferrer">EKS Network Load Balancer - IP Targets</a></p>
