Gateway API vs Ingress in Kubernetes

Kubernetes networking can be tricky, especially when you’re trying to expose your services to the outside world. Two common ways to do this are Ingress and the newer Gateway API.

Let’s look at what they are, how they differ, and when to use one over the other.

What is Ingress?

Ingress is a Kubernetes resource that defines how to route HTTP and HTTPS traffic to your services. It requires an Ingress Controller to actually implement the logic, such as NGINX or Traefik.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-service
                port:
                  number: 80

Pros of Ingress

  • Simple to set up
  • Works well for small to medium apps
  • Broad support

Cons

  • Limited flexibility for advanced routing
  • Tied to specific implementations
  • Difficult to extend

What is Gateway API?

Gateway API is a more modern and extensible alternative to Ingress. It provides a richer set of features, better separation of concerns, and consistent behavior across implementations.

It introduces new resources like:

  • GatewayClass
  • Gateway
  • HTTPRoute
  • TCPRoute

Example:

apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: my-gateway
spec:
  gatewayClassName: nginx
  listeners:
    - name: http
      port: 80
      protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: my-route
spec:
  parentRefs:
    - name: my-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: my-service
          port: 80

Key Differences

FeatureIngressGateway API
ExtensibilityLowHigh
CRD-basedNoYes
Multi-protocolLimited (HTTP/S)Supports TCP/UDP
Separation of RolesWeakStrong
Future of K8sLegacyModern

When to Use What?

  • Use Ingress for simpler, HTTP-based workloads.
  • Use Gateway API if you need flexibility, advanced routing, or want future-proof configurations.

Conclusion

Ingress is still useful and widely supported, but Gateway API is the future. If you’re starting fresh, Gateway API offers better long-term value and maintainability.