Process Flow - Path-based routing
Incoming HTTP Request
Check URL Path
Route to Service1
Response
Incoming requests are checked for their URL path and routed to different services based on the path prefix.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- http:
paths:
- path: /app1
pathType: Prefix
backend:
service:
name: service1
port:
number: 80
- path: /app2
pathType: Prefix
backend:
service:
name: service2
port:
number: 80| Step | Incoming Request Path | Path Match Check | Service Routed To | Action |
|---|---|---|---|---|
| 1 | /app1/home | Matches /app1 prefix | service1 | Request routed to service1 |
| 2 | /app2/dashboard | Matches /app2 prefix | service2 | Request routed to service2 |
| 3 | /app3/info | No matching path prefix | default backend or 404 | Request routed to default or rejected |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 |
|---|---|---|---|---|
| request_path | none | /app1/home | /app2/dashboard | /app3/info |
| matched_path | none | /app1 | /app2 | none |
| routed_service | none | service1 | service2 | default backend or 404 |
Path-based routing in Kubernetes Ingress: - Define multiple paths under rules.http.paths - Use pathType: Prefix for prefix matching - Requests routed to backend service matching first path prefix - Order of paths matters for overlapping prefixes - Unmatched paths go to default backend or 404