Gateway API
Gateway API is a modern, role-oriented API for service networking in Kubernetes. It’s designed as the evolution of Ingress, providing more expressive and extensible routing capabilities. Unlike Ingress which focuses on HTTP routing, Gateway API supports multiple protocols (HTTP, TCP, UDP, TLS) and provides role-based separation between infrastructure providers and application developers.
What is Gateway API?
Gateway API is a collection of Kubernetes resources that model service networking:
- Gateway - Defines how traffic enters the cluster
- GatewayClass - Defines types of Gateways
- HTTPRoute - Routes HTTP traffic
- TCPRoute, UDPRoute, TLSRoute - Route other protocols
Gateway API separates concerns:
- Infrastructure providers manage Gateways
- Application developers create Routes
Gateway API vs Ingress
Gateway API addresses limitations of Ingress:
Ingress limitations:
- Single resource for all configuration
- HTTP/HTTPS only
- Limited routing capabilities
- No role separation
Gateway API benefits:
- Multiple resources (Gateway, Routes)
- Multiple protocols
- Rich routing features
- Role-based access control
Core Resources
GatewayClass
Defines types of Gateways (similar to StorageClass):
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: example-gatewayclass
spec:
controllerName: example.com/gateway-controller
Gateway
Defines how traffic enters the cluster:
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: example-gateway
spec:
gatewayClassName: example-gatewayclass
listeners:
- name: http
protocol: HTTP
port: 80
- name: https
protocol: HTTPS
port: 443
tls:
mode: Terminate
certificateRefs:
- name: example-tls
HTTPRoute
Routes HTTP traffic to Services:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-route
spec:
parentRefs:
- name: example-gateway
hostnames:
- example.com
rules:
- matches:
- path:
type: PathPrefix
value: /api
backendRefs:
- name: api-service
port: 80
Role-Based Model
Gateway API separates infrastructure and application concerns:
Infrastructure Provider Role
Manages Gateways and GatewayClasses:
# Created by cluster admin
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: shared-gateway
spec:
gatewayClassName: nginx
listeners:
- name: http
protocol: HTTP
port: 80
Application Developer Role
Creates Routes that reference Gateways:
# Created by app developer
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: my-app-route
spec:
parentRefs:
- name: shared-gateway # References infrastructure Gateway
rules:
- matches:
- path:
type: PathPrefix
value: /my-app
backendRefs:
- name: my-app-service
port: 80
HTTPRoute Features
HTTPRoute provides rich routing capabilities:
Path Matching
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: path-route
spec:
parentRefs:
- name: example-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /api
backendRefs:
- name: api-service
port: 80
Header Matching
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: header-route
spec:
parentRefs:
- name: example-gateway
rules:
- matches:
- headers:
- name: version
value: v2
backendRefs:
- name: api-v2-service
port: 80
Traffic Splitting
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: split-route
spec:
parentRefs:
- name: example-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /api
backendRefs:
- name: api-v1-service
port: 80
weight: 90
- name: api-v2-service
port: 80
weight: 10
Request/Response Modification
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: modified-route
spec:
parentRefs:
- name: example-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /api
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
add:
- name: X-Forwarded-For
value: "true"
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /v1
backendRefs:
- name: api-service
port: 80
When to Use Gateway API
Use Gateway API when:
✅ Modern routing needs - Need advanced HTTP routing features
✅ Multiple protocols - Need TCP, UDP, or TLS routing
✅ Role separation - Want to separate infrastructure and application concerns
✅ Future-proofing - Gateway API is the direction Kubernetes is heading
✅ Rich features - Need traffic splitting, header matching, etc.
✅ Multi-tenant - Multiple teams sharing infrastructure
Consider Ingress when:
- Simple HTTP routing is sufficient
- You need immediate compatibility (Ingress is more widely supported)
- Your use case doesn’t need Gateway API features
Gateway API Status
Gateway API is evolving:
- v1.0 - Core HTTP routing (stable)
- v1.1 - Additional features (stable)
- v1.2+ - Ongoing development
Adoption:
- Supported by major Ingress Controllers (NGINX, Traefik, Istio)
- Cloud providers adding support
- Active development and community
Best Practices
- Evaluate your needs - Determine if Gateway API features are necessary
- Check controller support - Verify your controller supports Gateway API
- Use role separation - Leverage role-based model for multi-tenant clusters
- Start simple - Begin with basic routing, add complexity gradually
- Monitor adoption - Gateway API is evolving, stay updated
- Test thoroughly - Gateway API is newer, test your use cases
- Document routes - Keep HTTPRoute configurations documented
- Use namespaces - Organize routes by namespace
- Plan migration - If migrating from Ingress, plan carefully
- Leverage features - Use advanced features like traffic splitting when beneficial
Troubleshooting
Gateway Not Ready
- Check Gateway status:
kubectl get gateway <name> - Verify GatewayClass:
kubectl get gatewayclass - Check controller: Ensure Gateway API controller is running
- Review events:
kubectl describe gateway <name> - Check listeners: Verify listeners are configured correctly
HTTPRoute Not Working
- Check route status:
kubectl get httproute <name> - Verify parent reference: Ensure Gateway name is correct
- Check backend Services: Verify referenced Services exist
- Review route rules: Ensure rules are correctly configured
- Check controller logs: Review Gateway API controller logs
Traffic Not Routing
- Verify Gateway is ready: Check Gateway status
- Check HTTPRoute status: Look for acceptance/conditions
- Test backend Services: Verify Services work directly
- Review routing rules: Ensure matches are correct
- Check controller support: Verify controller supports used features
See Also
- Ingress - Traditional HTTP routing (Gateway API alternative)
- Ingress vs Gateway API - Comparison and migration guide
- HTTPRoute Details - Detailed HTTPRoute configuration
- Services - Backend Services that Routes reference