How to setup Kubernetes NLB Load Balancer with target group IP based AWS?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
On AWS, an NLB with IP targets sends traffic directly to pod IPs instead of routing through node ports on worker nodes. In Kubernetes, the usual way to get that behavior is to create a Service of type LoadBalancer and annotate it for the AWS Load Balancer Controller so it provisions an NLB with target type ip.
Why Use IP Targets
With instance targets, the NLB forwards traffic to nodes and then Kubernetes forwards again to pods. With IP targets, the NLB targets the pod IPs directly.
That can be useful for:
- reducing one network hop
- supporting Fargate workloads
- making health checks align more directly with pod endpoints
It also means your CNI and networking setup must support routable pod IPs in the VPC.
Service Manifest
For controller-managed NLB IP targets, the key annotations are:
- '
service.beta.kubernetes.io/aws-load-balancer-type: "external"' - '
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip"'
Example:
When this service is applied, the controller provisions the NLB and creates an IP-based target group for the selected pods.
Cluster Requirements
This setup is not just about annotations. You also need:
- the AWS Load Balancer Controller installed
- correct IAM permissions for the controller
- subnets tagged for load balancer discovery
- pod networking that gives pods reachable VPC IPs
On EKS, the Amazon VPC CNI is the standard way to provide pod IPs that can participate in IP target mode.
Health Checks and Port Mapping
The NLB target group health checks the pod traffic path represented by the service. If your application listens on 8080 and the service exposes port 80, the service maps the external port to the pod's real port through targetPort.
If you need custom health-check behavior, additional service annotations can refine protocol and port choices, but the base service should work first before you start tuning those options.
Do Not Mutate Key Annotations Casually
For NLB type and target-type annotations, the safest practice is to create the service correctly from the start. Changing these core annotations after creation can lead to controller reconciliation issues or require the service to be recreated, depending on the controller behavior and environment.
That is why infrastructure teams usually treat these annotations as part of the service identity, not as runtime toggles.
Common Pitfalls
The most common mistake is enabling IP targets without a networking setup that supports pod IP reachability from the load balancer. If the pods are not reachable at the VPC level, health checks fail.
Another issue is forgetting that the AWS Load Balancer Controller must be installed and authorized. The service annotations by themselves do nothing if no controller is watching them.
A third pitfall is mixing older and newer annotation styles without understanding which controller owns the service. Keep the manifest aligned with the controller you actually run.
Finally, do not assume IP mode is automatically better in every case. It changes the traffic path and operational model, so use it when direct pod targeting is the behavior you actually need.
Summary
- On AWS, an NLB with IP targets routes traffic directly to pod IPs.
- In Kubernetes, this is typically configured through a
LoadBalancerservice plus AWS controller annotations. - The AWS Load Balancer Controller, IAM permissions, subnet tagging, and pod networking must all be in place.
- Create the service with the correct target-type annotations from the beginning.
- Use IP mode when direct pod targeting fits your networking and workload needs.
Related reading
- How to share a file from initContainer to base container in Kubernetes
- How to share an EFS volume across multiple namespaces
- How to share storage between Kubernetes pods?
- How to sign in kubernetes dashboard?
- How to simplify aws DynamoDB query JSON output from the command line?
- How to solve -Cannot use import statement outside a module in AWS lambda console
- How to solve error running pod install in flutter on mac?
- How to specify a cluster name for a kubernetes cluster
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.