Kubernetes Ingress vs LoadBalancer: Which to Choose?
Detailed comparison of Kubernetes Ingress and LoadBalancer services — when to use each, what they actually provision in your cloud, cost implications, and the pitfalls that catch people in production.
Table of Contents
- The Quick Answer
- How Each Works
- Side-by-Side Comparison
- Configuration Examples
- Cost Analysis
- What about NodePort?
- When to Use LoadBalancer
- When to Use Ingress
- Common Pitfalls
- Decision Guide
The Quick Answer
- LoadBalancer: One cloud LB per service — simple but expensive at scale
- Ingress: One LB, many routes — cheaper, smarter routing, TLS in one place
For anything beyond a few services, use Ingress.
How Each Works
LoadBalancer Service
Each type: LoadBalancer service provisions a real cloud load balancer:
Internet → LB1 → service-a
Internet → LB2 → service-b
Internet → LB3 → service-c
On Azure, each LoadBalancer service gets its own public IP + Azure LB rule. On AWS, an NLB/ALB per service (depending on annotations). The cloud controller manager in your cluster talks to the cloud API and provisions the real thing — which is why kubectl get svc shows EXTERNAL-IP as <pending> until the cloud finishes.
Ingress
One ingress controller (nginx, Traefik, Azure AGIC) sits behind one LoadBalancer and routes by hostname/path:
Internet → ONE LB → Ingress Controller → service-a (host: api.example.com)
→ service-b (host: app.example.com)
→ service-c (host: example.com/blog)
The controller itself is just pods watching Ingress objects — you still need one LoadBalancer (or NodePort) in front of it, but that one LB serves every route the controller manages. Ten services, one cloud LB.
Side-by-Side Comparison
| Feature | LoadBalancer | Ingress |
|---|---|---|
| OSI Layer | L4 (TCP/UDP) | L7 (HTTP/HTTPS) |
| Routing | IP:port only | Host + path based |
| TLS termination | Per-service | Centralized |
| Cloud resources | 1 LB per service | 1 LB total |
| URL rewriting | No | Yes |
| Rate limiting/WAF | No (cloud LB dependent) | Yes (controller features) |
| Non-HTTP traffic | Yes | No (mostly) |
| Client IP preservation | externalTrafficPolicy: Local | Via X-Forwarded-For / PROXY protocol |
| Complexity | Low | Medium |
Configuration Examples
LoadBalancer Service
apiVersion: v1
kind: Service
metadata:
name: my-app-lb
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
kubectl get svc my-app-lb
# EXTERNAL-IP shows once the cloud provider provisions the LB
One detail that matters: externalTrafficPolicy. Default Cluster SNATs traffic through any node — the backend pod sees the node's IP, not the client's. Local preserves the client IP but only routes to nodes that actually run a pod — pick deliberately, it's a behavioral difference, not a toggle.
Ingress Setup
Step 1: Install the ingress controller (nginx):
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install ingress-nginx ingress-nginx/ingress-nginx \
-n ingress-nginx --create-namespace
On AKS, alternatively enable Application Gateway Ingress Controller (AGIC) or the managed nginx addon:
az aks enable-addons --addons ingress-appgw \
--resource-group my-rg --name my-cluster \
--appgw-name my-appgw --appgw-subnet-id <subnet-id>
Step 2: Create the Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /api(/|$)(.*)
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- path: /(/|$)(.*)
pathType: Prefix
backend:
service:
name: frontend-service
port:
number: 80
- host: admin.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: admin-service
port:
number: 8080
Step 3: Add TLS with cert-manager — see our Ingress and TLS guide for the full cert-manager + Let's Encrypt setup:
spec:
tls:
- hosts:
- example.com
- admin.example.com
secretName: app-tls
Cost Analysis
Approximate costs (varies by region/provider):
| Setup | Monthly Cost |
|---|---|
| 10 LoadBalancer services (Azure) | ~£150+ (10 public IPs + LB rules) |
| 1 Ingress + 10 routes | ~£18–25 (1 public IP + controller pods) |
At 50+ services, LoadBalancer-per-service becomes genuinely expensive and hits cloud provider limits (LB rules per LB, public IPs per subscription). Ingress's cost is flat — the controller pods scale with traffic, not service count.
What about NodePort?
type: NodePort exposes the service on a high port (30000–32767) on every node's IP — no cloud LB provisioned at all. It's the primitive LoadBalancer builds on (a cloud LB forwards to nodePorts), and it's what you reach for on bare-metal clusters where no cloud LB exists, or when an external LB you already own fronts the cluster. For public cloud, LoadBalancer or Ingress is almost always the better end state — NodePort is plumbing, not product.
When to Use LoadBalancer
- Single service that needs direct exposure (a game server, an MQTT broker, a bastion)
- Non-HTTP protocols — TCP/UDP that L7 ingress can't route
- Simplest possible setup for a demo or MVP — no controller to install
- Client IP matters and SNAT isn't acceptable —
externalTrafficPolicy: Localpreserves it cleanly at L4
When to Use Ingress
- Multiple HTTP(S) services — the common case; one LB, many routes
- Path-based routing (
/api→ api-svc,/→ frontend) - Hostname routing (api.example.com, admin.example.com on one IP)
- Centralized TLS via cert-manager + Let's Encrypt — cert lifecycle in one place
- Rate limiting, auth, rewrites, WAF at the edge — controller annotations, not app code
Common Pitfalls
Ingress returns 404 for everything
# Check the ingress got an address
kubectl get ingress
# Check controller logs
kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx
# Common cause: missing ingressClassName
spec:
ingressClassName: nginx # required in modern Kubernetes
Without ingressClassName, no controller claims the Ingress and it sits there doing nothing — the single most common "Ingress doesn't work" cause.
Health probes failing through ingress
The ingress controller routes to ready pods only. If readiness probes fail, the Service has no endpoints and the controller returns 503 — check our Pod Not Ready guide for the probe debugging flow.
SSL redirect loops
# If terminating TLS at a cloud LB or CDN in front of ingress:
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false" # avoid double-redirect loop
If something upstream already redirects HTTP→HTTPS, the controller's own redirect creates a loop that browsers report as ERR_TOO_MANY_REDIRECTS.
LoadBalancer stuck in <pending>
The cloud controller manager needs IAM permissions to create LBs — on self-managed clusters or fresh accounts, missing permissions or missing cloud integration is the usual reason EXTERNAL-IP never appears.
Decision Guide
Need non-HTTP (TCP/UDP)? ──yes──→ LoadBalancer
│
no
▼
More than 2-3 services? ──yes──→ Ingress
│
no
▼
Quick demo/MVP? ──yes──→ LoadBalancer
│
no
▼
→ Ingress (better long-term)
Related Articles
Our tutorials and troubleshooting runbooks are written by a DevOps practitioner with hands-on experience operating Kubernetes, Terraform, CI/CD pipelines, and Linux infrastructure in production. Commands, manifests, and configurations are verified against current tooling releases. Learn more about our editorial process or report a correction or outdated flag.