Kubernetes Ingress
Route HTTP and HTTPS traffic into your cluster with Ingress rules, controllers, TLS termination, and host or path based routing.
What Is Ingress?
An Ingress is a Kubernetes API resource for HTTP and HTTPS routing. It does not handle traffic by itself. An Ingress Controller such as NGINX or Traefik watches Ingress resources and implements the routing behavior.
Why Use Ingress?
Ingress lets you:
- route by host name
- route by URL path
- terminate TLS centrally
- share one public entry point across many services
Ingress vs LoadBalancer Service
| Topic | Ingress | LoadBalancer Service |
|---|---|---|
| Routing level | Layer 7 HTTP/HTTPS | Layer 4 network exposure |
| Multiple apps | Great fit | Often one LB per Service |
| TLS termination | Common feature | Possible but less centralized |
| Path routing | Yes | No native path rules |
Traffic Diagram
Internet → Ingress Controller → Services → Pods
Internet
app.example.com
Ingress Controller
NGINX / Traefik
/api → api-service:80
/web → web-service:80
Service
api-service
api-pod-1, api-pod-2
Service
web-service
web-pod-1, web-pod-2
Path-Based Routing Example
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
spec:
rules:
- host: example.local
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
Host-Based Routing Example
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: host-ingress
spec:
rules:
- host: api.example.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- host: app.example.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
TLS Termination Example
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tls-ingress
spec:
tls:
- hosts:
- app.example.local
secretName: app-tls
rules:
- host: app.example.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
Why the Controller Matters
Without an Ingress Controller, the Ingress resource is only a rule definition. The controller is the actual traffic manager.
Think of Ingress as the route map and the Ingress Controller as the traffic police who enforce it.
Controller Need
Why is an Ingress Controller required?
Path Routing
Which Kubernetes resource is best suited for routing `/api` to one service and `/` to another over HTTP?