Amazon EKS — NLB Services
NLB Services
The Network Load Balancer (NLB) operates at Layer 4 (TCP/UDP). It handles millions of requests per second with ultra-low latency. Use NLB for non-HTTP workloads.
Create NLB Service
apiVersion: v1
kind: Service
metadata:
name: my-nlb
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: external
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
spec:
type: LoadBalancer
selector:
app: web
ports:
- port: 80
targetPort: 8080
protocol: TCP
ALB vs NLB
| Feature | ALB | NLB |
|---|---|---|
| Layer | 7 (HTTP/HTTPS) | 4 (TCP/UDP) |
| Path routing | ✅ Yes | ❌ No |
| SSL termination | ✅ Yes | ✅ Yes (TLS) |
| WebSocket | ✅ Yes | ✅ Yes |
| Static IP | ❌ No | ✅ Yes (Elastic IP) |
| Ultra-low latency | No | ✅ Yes |
| Cost | ~$18/month + LCU | ~$18/month + NLCU |
| Best for | HTTP APIs, websites | TCP services, gRPC, gaming |
Common Mistakes
| Mistake | Impact |
|---|---|
| Using ALB for TCP/UDP workloads | ALB only supports HTTP/HTTPS |
| NLB for HTTP path routing | NLB can’t do path-based routing |
Missing external type annotation |
Gets legacy Classic LB |
What’s Next?
HTTPS setup: SSL/TLS Termination.