Skip to main content
< All Topics

Kubernetes Gateway API

Hello learners, and welcome back to DevSecOpsGuru.in! Today, we are going to dive deep into a massive shift in the Kubernetes networking world: the Kubernetes Gateway API. If you have ever struggled with messy Ingress files, this is the modern, standardized, and highly flexible upgrade you have been waiting for.

Let’s break this down completely, from beginner-friendly concepts to production-grade DevSecOps architecture!

When you deploy applications in Kubernetes, you need a safe way for the outside world (your users) to access them. For years, the standard tool was “Ingress.” However, as apps grew complex, Ingress became too rigid and hard to manage for large teams.

Enter the Kubernetes Gateway API! Think of it as “Ingress 2.0.” It is a modern, standardized set of rules to manage network traffic entering and leaving your cluster. It supports multiple protocols (HTTP, HTTPS, TCP, UDP, gRPC) and allows different teams (like infrastructure admins and app developers) to work together safely without breaking each other’s configurations.

Imagine a large, modern apartment building:

  • NodePort/LoadBalancer (The Old Way): This is like giving everyone outside a direct, unmanaged phone line to every single flat. It is messy, expensive, and insecure!
  • Legacy Ingress: Think of this as a receptionist at the front desk who only speaks English (HTTP) and uses a very basic notebook to direct guests. If you need special VIP rules, the receptionist gets confused unless you hand them messy custom sticky notes (which are like Kubernetes annotations).
  • Gateway API (The Modern Way): This is a high-tech, smart lobby system. It has a Building Manager (Infrastructure Team) who sets up the physical security gates (GatewayClass and Gateway). Then, the individual Flat Owners (Developers) can set up their own digital smart-passes (HTTPRoute, TCPRoute) to let their specific guests in. It speaks multiple languages natively and handles everything smoothly without bothering the building manager for every single visitor!

Key details to remember

  • Gateway API ≠ API Gateway: Gateway API is a set of Kubernetes rules/resources, while an API Gateway (like Kong or NGINX) is the actual software doing the proxy work.
  • Role-Oriented: Designed for different personas (Platform Admins manage Gateways, Developers manage Routes).
  • Expressive: Natively supports header matching, traffic splitting, and weight-based routing without messy annotations.
  • Multi-Protocol: Supports HTTP, HTTPS, TCP, UDP, and gRPC out of the box.
  • Standardized: Replaces fragmented, vendor-specific Ingress controllers with a universal, portable Kubernetes standard.
FeatureLegacy Kubernetes IngressModern Gateway API
Protocol SupportMostly HTTP/HTTPSHTTP, HTTPS, gRPC, TCP, UDP
Role SeparationBlurry (Devs & Admins fight over 1 file)Clear (Admin = Gateway, Dev = Route)
Traffic Splitting (Canary)Requires vendor-specific annotationsBuilt-in natively
Cross-Namespace RoutingHard or impossibleNatively supported via ReferenceGrant

The Evolution of From Ingress to Gateway API

While Ingress was a foundational tool in the early days of Kubernetes, its rigid design struggled to keep up with modern networking demands. The Gateway API was introduced as a robust, standardized replacement to solve the growing pains associated with Ingress.

The Limitations of Traditional Ingress (Why We Left)

  • Protocol Limitations: Ingress was strictly designed for Layer 7 traffic (HTTP/HTTPS). Routing Layer 4 traffic (like TCP or UDP) was impossible without implementing custom, non-standard workarounds.
  • “Annotation Hell” and Vendor Lock-in: Because Ingress only understood basic HTTP/HTTPS, vendors (like NGINX or Traefik) had to invent custom YAML annotations (e.g., nginx.ingress.kubernetes.io/rewrite-target) to support advanced features like rate limiting, traffic splitting, header manipulation, or retries. This destroyed portability if you migrated to a new Ingress controller, your YAML files would break.
  • Single Persona Bottleneck: Ingress forced both infrastructure configuration (e.g., port binding, TLS) and application routing (e.g., path mapping) into a single object. This made it incredibly difficult to implement Role-Based Access Control (RBAC) across different engineering teams safely.

How Gateway API Fixes the Problem

The Gateway API provides a much larger, native vocabulary inside Kubernetes, standardizing advanced networking features into the core specification so you no longer have to rely on vendor-specific annotations.

  • Broad Protocol Support: Gateway API natively supports HTTP, gRPC, TCP, UDP, and TLS straight out of the box.
  • Role-Oriented Architecture: Instead of a single crowded Ingress.yaml file, the Gateway API separates concerns by splitting the configuration into distinct resources. This allows cluster administrators and application developers to work independently without stepping on each other’s toes.

The Role-Oriented Model of Gateway API

Think of the Kubernetes Gateway API like a set of Lego blocks. By cleanly separating infrastructure configuration from application routing, teams only need to manage the YAML files they are directly responsible for. This role-based design makes cluster networking significantly more secure, scalable, and manageable for everyone involved.

The architecture is smartly split across three distinct personas and their respective resources:

1. GatewayClass (The Blueprint)

  • Owned by: Infrastructure Provider / Platform Team
  • Purpose: Acts as a template defining the underlying load balancer or controller technology (e.g., NGINX, AWS ALB, Istio, Envoy, or Cilium).
  • Key Detail: A single Kubernetes cluster can support multiple GatewayClasses simultaneously. For example, you might create an external-lb class for public internet traffic and an internal-lb class for private, cross-service corporate traffic.

2. Gateway (The Infrastructure Layer)

  • Owned by: Cluster Operator / Admin
  • Purpose: The actual instantiation of a GatewayClass. It requests and provisions the specific load balancer configuration from the infrastructure provider.
  • Example: “I am opening Port 80 on the cluster and allowing traffic.”
  • Listeners: Inside the Gateway spec, operators define “Listeners” to control the entry points. Listeners specify the logical endpoints (e.g., Port 80 for HTTP, Port 443 for HTTPS), manage TLS certificates, and dictate exactly which namespaces are authorized to attach routes to this Gateway.

3. *Route (The Traffic Intelligence)

  • Owned by: Application Developer
  • Purpose: Defines the application-specific traffic routing logic that snaps into the Gateway.
  • Example: “If traffic hits Port 80 and the path is /app, send it to my specific Kubernetes Service.”
  • Strong Typing: Instead of generic routes, developers use highly typed resources depending on the specific traffic, such as HTTPRoute, GRPCRoute, TCPRoute, or UDPRoute.

These Route resources contain the actual intelligence for the traffic lifecycle, which is broken down into three main mechanisms:

MechanismDescription
MatchesThe rules for intercepting traffic based on paths, headers, query parameters, or specific HTTP methods.
FiltersActions taken on the request before it reaches the backend. Examples include adding or removing headers, request mirroring, URL rewriting, or setting retry budgets.
BackendsThe final destination for the traffic. This is usually a standard Kubernetes Service, but it can also be a custom target like a cloud storage bucket.

Advanced Concepts & Capabilities

Cross-Namespace Routing (Safe Multi-Tenancy)

One of the most powerful features of the Gateway API is its ability to decouple the Gateway from the application routes.

  • allowedRoutes: A Cluster Operator can deploy a shared Gateway in a gateway-infra namespace and configure the Listener’s allowedRoutes to accept HTTPRoutes from the app-team-a and app-team-b namespaces.
  • ReferenceGrant: If Team A wants their HTTPRoute to forward traffic to a Service in Team B’s namespace, they can’t just do it blindly (which would be a security risk). Team B must explicitly create a ReferenceGrant resource to permit Team A’s route to send traffic to their service.

The GAMMA Initiative (Service Mesh Integration)

Originally, the Gateway API was designed for North-South traffic (traffic entering the cluster from the outside). However, through the GAMMA (Gateway API for Mesh Management and Administration) initiative, the exact same API is now used for East-West traffic (traffic between microservices inside the cluster). Instead of attaching an HTTPRoute to a Gateway, you can attach it directly to a Kubernetes Service to define mesh routing rules.

Extensibility and AI Workloads

Because it relies on Custom Resource Definitions (CRDs), the Gateway API is highly extensible. A prime example is the recent Gateway API Inference Extension, which allows the API to intelligently route traffic to Large Language Models (LLMs) based on GPU availability, token cache, and model criticality, effectively turning a standard Gateway into an “AI Gateway.”You’ve got a great grasp of the core concepts! Your summary perfectly captures the essence of the Kubernetes Gateway API. To build on that foundation, here is a deeper dive into the architecture, advanced capabilities, and the specific problems this API was built to solve.

Why Gateway API is Replacing Ingress

The traditional Kubernetes Ingress resource is now officially frozen, meaning all new network routing features are being developed exclusively for the Gateway API. The shift was necessary because Ingress had several structural limitations:

  • Protocol Limitations: Ingress was strictly designed for Layer 7 (HTTP/HTTPS). Routing Layer 4 traffic (TCP/UDP) required custom workarounds. Gateway API natively supports HTTP, gRPC, TCP, UDP, and TLS out of the box.
  • Annotation Hell: Because Ingress was a single, rigid resource, advanced features like traffic splitting, header manipulation, or retries were implemented via vendor-specific annotations (e.g., nginx.ingress.kubernetes.io/rewrite-target). This destroyed portability across different Ingress controllers. Gateway API standardizes these features into the core specification.
  • Single Persona Bottleneck: Ingress forced infrastructure configuration and application routing into the same object, making it difficult to define Role-Based Access Control (RBAC) across different teams.

The Role-Oriented Model

As you noted, the API is split across three personas. Here is a closer look at what each resource actually does under the hood:

  • GatewayClass (Infrastructure Provider): Think of this as the “template” or “blueprint.” It defines which controller will actually manage the traffic (e.g., Istio, Envoy, Cilium, NGINX). You can have multiple GatewayClasses in a single cluster—for example, an external-lb class for public internet traffic and an internal-lb class for private corporate traffic.
  • Gateway (Cluster Operator):This is the actual instantiation of a GatewayClass. It requests a specific load balancer configuration from the infrastructure provider.
    • Listeners: Inside the Gateway spec, operators define “Listeners” which specify the logical endpoints (e.g., Port 80 for HTTP, Port 443 for HTTPS), the TLS certificates to use, and exactly which namespaces are allowed to attach routes to this Gateway.
  • *Route (Application Developer):The routing layer is highly typed. You don’t just use a generic route; you use an HTTPRoute, GRPCRoute, TCPRoute, or UDPRoute. These resources contain the actual intelligence:
    • Matches: Rules based on paths, headers, query parameters, or HTTP methods.
    • Filters: Actions taken on the request before it hits the backend (e.g., adding/removing headers, request mirroring, URL rewriting, or setting retry budgets).
    • Backends: Where the traffic ultimately goes (usually a Kubernetes Service, but it can also be a custom backend like a cloud storage bucket).

ReferenceGrant: A powerful security feature that allows safe sharing of resources across different namespaces (e.g., routing traffic from a Gateway in a platform namespace to a Service in a dev namespace).

Advanced Concepts & Capabilities

Cross-Namespace Routing (Safe Multi-Tenancy)

One of the most powerful features of the Gateway API is its ability to decouple the Gateway from the application routes.

  • allowedRoutes: A Cluster Operator can deploy a shared Gateway in a gateway-infra namespace and configure the Listener’s allowedRoutes to accept HTTPRoutes from the app-team-a and app-team-b namespaces.
  • ReferenceGrant: If Team A wants their HTTPRoute to forward traffic to a Service in Team B’s namespace, they can’t just do it blindly (which would be a security risk). Team B must explicitly create a ReferenceGrant resource to permit Team A’s route to send traffic to their service.

The GAMMA Initiative (Service Mesh Integration)

Originally, the Gateway API was designed for North-South traffic (traffic entering the cluster from the outside). However, through the GAMMA (Gateway API for Mesh Management and Administration) initiative, the exact same API is now used for East-West traffic (traffic between microservices inside the cluster). Instead of attaching an HTTPRoute to a Gateway, you can attach it directly to a Kubernetes Service to define mesh routing rules.

Extensibility and AI Workloads

Because it relies on Custom Resource Definitions (CRDs), the Gateway API is highly extensible. A prime example is the recent Gateway API Inference Extension, which allows the API to intelligently route traffic to Large Language Models (LLMs) based on GPU availability, token cache, and model criticality, effectively turning a standard Gateway into an “AI Gateway.”

DevSecOps Architects, let’s talk about production-grade deployments. In a true enterprise environment, the Gateway API is the ultimate enabler for secure, zero-trust, edge-to-mesh architectures.

  • Edge-to-Mesh Integration (GAMMA): Modern implementations allow you to use the Gateway API not just for North-South traffic (entering the cluster), but also for East-West traffic (service-to-service via a Service Mesh). The GAMMA (Gateway API for Mesh Management and Administration) initiative is bringing Service Mesh routing into this exact same API standard, unifying edge and mesh configurations.
  • Zero-Trust and Security: You can enforce TLS termination at the Gateway layer using hardened certificates from cert-manager, while using ReferenceGrant to strictly control which namespaces can attach routes to the corporate Gateway. This prevents a compromised developer namespace from hijacking the main domain’s traffic or spoofing routes.
  • Production Tooling & Implementations: You cannot just apply the Gateway API CRDs and expect it to work; you need a conformant data-plane controller. Here are the top production-grade tools supporting this natively:
    • Istio: Excellent for full Service Mesh + Gateway capabilities. Official Website
    • Cilium / Isovalent: Powered by eBPF, insanely fast, great for DevSecOps network policies. Official Website
    • Envoy Gateway: The official Gateway API implementation driven by the Envoy proxy community. Official Website
    • Kong Gateway Operator: High-performance, highly scalable API gateway. Official Website
    • NGINX Gateway Fabric: F5/NGINX’s official conformance tool for the new standard. Official Website
Additional Details
  • The “API Gateway” vs “Gateway API” Confusion: Let’s clear up a massive industry confusion. Gateway API is a Kubernetes specification (a bunch of CRDs). An API Gateway (like Apigee, Kong, AWS API Gateway) is a software product that handles rate limiting, billing, and auth. You can actually use the Gateway API specs to configure your API Gateway product inside Kubernetes!
  • State of the API: As of late 2023/2024, the Gateway API hit v1 (General Availability) for core features like HTTPRoute, Gateway, and GatewayClass. TCP/UDP routing is still evolving but highly usable in beta.
  • Ingress is NOT fully deprecated yet: It is “frozen.” No new features are being added to standard Ingress, but it will stick around for a long time. However, all new open-source networking development is happening in the Gateway API space.
Key Components
  1. GatewayClass: Created by the Infrastructure Provider (e.g., AWS, Azure, or your Platform team). It defines the type of load balancer or proxy to use (like NGINX, Istio, or Envoy).
  2. Gateway: Created by the Cluster Operator. It represents an actual instance of the traffic-handling infrastructure (like a physical or cloud load balancer listening on port 80 or 443).
  3. Routes (HTTPRoute, TCPRoute, UDPRoute): Created by Application Developers. These define the actual rules—how a request like /login should be safely routed to the backend login-service pod.
  4. ReferenceGrant: A powerful security feature that allows safe sharing of resources across different namespaces (e.g., routing traffic from a Gateway in a platform namespace to a Service in a dev namespace).
Key Characteristics
  • Role-Oriented Design: It separates the duties. Your infrastructure team manages the heavy lifting, and your dev team manages the app routing. No more accidental configuration breaks!
  • Extensible & Portable: You can easily swap out your underlying proxy (e.g., moving from Traefik to Envoy) without rewriting all your developer routing rules.
  • Highly Expressive: You can route traffic based on HTTP headers, methods, query parameters, and easily split traffic for testing out of the box.
Use Cases
  • Multi-Tenant Clusters: Safely sharing a single load balancer across multiple application teams using different namespaces.
  • Advanced Deployments: Doing smooth Canary deployments or Blue-Green deployments with native traffic weighting.
  • Non-HTTP Traffic: Routing database traffic (TCP) or video streaming (UDP) right alongside your web traffic.
Benefits
  • No more “annotation soup” cluttering up your YAML files.
  • Better security through strict RBAC (Role-Based Access Control) boundaries.
  • Vendor neutrality—write your configurations once, and run them anywhere.
Best Practices
  • Adopt Role Segregation: Let your Platform team handle GatewayClass and Gateway. Empower devs to handle Routes.
  • Use ReferenceGrants Carefully: Only grant cross-namespace access when absolutely necessary to maintain a secure, zero-trust environment.
  • Migrate Gradually: Don’t rip out Ingress overnight. Run your Ingress controllers and Gateway API side-by-side during migration to test the waters.
  • Challenge: Complexity Overhead.
    • Problem: For a simple 1-node sandbox, deploying GatewayClass, Gateway, and HTTPRoute feels like YAML bloat compared to one simple Ingress file.
    • Solution: Use it where it makes sense. If you have a single tiny app, standard Ingress is fine. Scale to Gateway API when teams grow.
  • Challenge: Controller Conflicts.
    • Problem: Running an old Ingress Controller and a new Gateway API Controller on the same ports causes binding failures.
    • Solution: Ensure proper IP allocation or use different load balancer IPs/ports for testing them side-by-side during migration.
  • Limitation: Vendor Feature Parity.
    • Problem: Not all controllers support 100% of the Gateway API spec yet (e.g., UDP routing might be missing in some).
    • Solution: Always verify the official Kubernetes Gateway API Conformance page before choosing a production tool.
  • Istio: Excellent for full Service Mesh + Gateway capabilities.
  • Cilium / Isovalent: Powered by eBPF, insanely fast, perfect for DevSecOps network policies.
  • Envoy Gateway: The official Gateway API implementation driven by the Envoy proxy community.
  • Kong Gateway Operator: High-performance, highly scalable API gateway.
  • NGINX Gateway Fabric: F5/NGINX’s official conformance tool for the new standard.
Contents
Scroll to Top