Sub topic 1
Why the Gateway API: limits of Ingress
Prerequisites
This chapter assumes you know the following:
- Pods, Services, Namespaces, and labels.
- How to apply YAML manifests with
kubectl. - HTTP hosts, paths, headers, and status codes.
- What an Ingress or load balancer does at a general level.
What Ingress does well
An Ingress is a Kubernetes object that routes external HTTP and HTTPS traffic to Services. An Ingress controller, such as ingress-nginx or Traefik, watches Ingress objects and configures a proxy to match them. A simple rule is easy to write:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: shop
namespace: shop-team
spec:
ingressClassName: nginx
rules:
- host: shop.example.com
http:
paths:
- path: /cart
pathType: Prefix
backend:
service:
name: cart-svc
port:
number: 8080This works for host and path routing. Problems appear when you need more.
Where Ingress falls short
- Small feature set. The spec covers hosts, paths, and TLS. Header matching, traffic weights, redirects, and rewrites are not part of it.
- Annotations fill the gap. Each controller defines its own annotations for these features. A canary rollout on ingress-nginx uses annotations like
nginx.ingress.kubernetes.io/canary-weight. Another controller uses different keys or none at all. Annotations are untyped strings, so the API server cannot validate them. A typo is silently ignored. - Portability suffers. Moving to another controller means rewriting annotations, and some features may not exist there.
- One object serves everyone. A single Ingress mixes infrastructure settings (TLS certificates, load balancer behavior) with application routing. Giving developers permission to edit it also gives them control over shared infrastructure.
- Limited protocols and status. Ingress targets HTTP and HTTPS. It has little structured status for explaining why a rule is not working.
The Gateway API approach
The Gateway API is a set of Custom Resource Definitions (CRDs) maintained by the Kubernetes SIG Network project. It replaces annotations with typed fields that the API server validates. Features such as header matching, weighted backends, and filters are part of the spec, so the same manifest behaves consistently across conforming implementations.
It also splits the one Ingress object into separate resources for separate owners:
| Concern | Ingress | Gateway API |
|---|---|---|
| Which controller runs | `ingressClassName` | GatewayClass |
| Entry point, ports, TLS | Mixed into the Ingress | Gateway |
| Routing rules | Same Ingress object | HTTPRoute |
| Extra features | Controller annotations | Typed fields and filters |
| Cross-namespace control | Mostly by convention | `allowedRoutes`, ReferenceGrant |
Later chapters cover each resource in detail.
A practical decision rule
Ingress is still reasonable for a small cluster with simple host and path routing and one team. Consider the Gateway API when you need any of these:
- Several teams sharing one entry point with clear boundaries.
- Header-based routing or weighted traffic splitting.
- Portable configuration across controllers.
- Clear status reporting for debugging.
Exercise
Name two problems that come from using controller-specific annotations to configure an Ingress, and say how the Gateway API addresses them.
Show answer
Annotations are untyped strings, so the API server cannot validate them and typos are silently ignored. They are also specific to one controller, so configuration is not portable. The Gateway API replaces them with typed, validated fields in the spec, and conforming implementations interpret those fields the same way.