AWS API Gateway vs Kubernetes Gateway API: learn the difference by building both
Two names, one easy misunderstanding.
AWS API Gateway is an AWS-managed service for publishing APIs and controlling consumer access. Kubernetes Gateway API is a set of Kubernetes networking APIs that a controller implements using a traffic proxy or cloud load balancer.
They overlap in HTTP routing. Either can be sufficient for some applications. They can also work together when consumer-facing API management and application traffic management need separate controls.
The clearest way to learn the difference is to keep one application and change how traffic reaches it.
This article proposes that project. The manifests illustrate the design; they are not a complete deployment bundle or evidence of a completed lab. Verify controller, CRD, Helm chart, and Terraform provider compatibility before implementation. Product capabilities below were checked against official documentation on November 28, 2026.
One application, three architectures
Imagine an e-commerce platform with three microservices on EKS:
| Service | Endpoint | Access requirement |
|---|---|---|
| Products | GET /products |
Public |
| Orders | GET /orders |
Valid access token with order-read permission |
| Payments | POST /payments |
Valid access token with payment-write permission |
Use mock payments throughout. Return a service name and application version in every response so routing decisions are observable. Give each workload a separate readiness endpoint.
Build these architectures sequentially:
| Architecture | Consumer-facing entry | Application routing |
|---|---|---|
| A | AWS API Gateway HTTP API | Internal ALB configured through Ingress |
| B | Public NLB forwarding to Envoy | Envoy configured through Gateway API |
| C | AWS API Gateway HTTP API | Private NLB forwarding to Envoy, configured through Gateway API |
Use one cluster within a working session. Keep the three services stable while replacing the exposure layer, and remove unused load balancers as you move between designs.
Architecture A: AWS API Gateway with an internal ALB
Customer
| HTTPS
v
AWS API Gateway HTTP API
| JWT authorization and API throttling
v
VPC Link
v
Internal ALB
| path-based rules
+--> product pods
+--> order pods
+--> payment pods
Configuration: Ingress --> AWS Load Balancer Controller --> ALB
An Ingress resource describes the ALB routing rules. It is configuration, not a process handling requests. With IP targets, the ALB sends requests to pod IPs; the Kubernetes Services provide backend discovery rather than an additional proxy hop in this diagram.
Build
Use Terraform for the VPC, private and public subnets as needed, EKS managed node groups, IAM, HTTP API, VPC Link, Cognito, and CloudWatch log configuration. Use Argo CD and Helm for the AWS Load Balancer Controller and Kubernetes workloads, including three Deployments, three ClusterIP Services, and an Ingress.
Configure the Ingress for an internal ALB with IP targets and rules for /products, /orders, and /payments. Its health-check path must reach a healthy endpoint on each backend.
Define these API Gateway routes:
| Route | Authorization | Integration |
|---|---|---|
GET /products |
None | Internal ALB listener |
GET /orders |
JWT, required order-read scope | Same listener |
POST /payments |
JWT, required payment-write scope | Same listener |
All three can share one HTTP proxy integration. Configure its integration method as ANY so it forwards both GET and POST requests. The API routes still restrict the externally accepted methods.
For an HTTP API private integration, supply the load balancer listener ARN, with the VPC Link as the connection. The API, link, and load balancer must belong to the same AWS account. If a named stage reaches your backend as /lab/products, map the integration request path to $request.path so the backend receives /products. Backend HTTPS requires explicit TLS configuration; a private connection does not automatically encrypt that hop. See AWS private integration guidance.
Prove
- Call products without a token and expect success.
- Call orders without a token and expect rejection.
- Sign in through Cognito using an appropriate OAuth flow, obtain an access token, and call orders successfully.
- Send an expired token or a token from an untrusted issuer and confirm rejection.
- Send a valid token without the required scope and confirm access is denied.
- Configure low rate and burst targets, generate controlled load, and capture
429responses. - Compare access logs and latency metrics with a deliberately slow mock backend.
- Verify the ALB scheme, subnet placement, security-group rules, and failure of direct access from outside the VPC.
JWT validation checks the token's signature, issuer, audience/client identifier, lifetime, and configured scopes. Application authorization still matters: an authenticated customer must not be able to read another customer's orders. See HTTP API JWT authorization.
What this teaches: API Gateway owns the public API contract and initial access checks. The ALB selects an application backend.
Architecture B: Kubernetes Gateway API with Envoy
Remove Architecture A's Ingress and unused API management resources, then expose the same services through Envoy.
Customer --HTTPS--> Public NLB --TCP--> Envoy proxy --> application pods
^
| configured by
Envoy Gateway controller
^
| watches
GatewayClass + Gateway + HTTPRoutes
The NLB forwards connections. In this design, Envoy terminates TLS and routes HTTP requests. An NLB can terminate TLS in other designs; here it uses a TCP listener to preserve the encrypted connection to Envoy.
Gateway API resources describe desired behavior. Requests do not travel through an HTTPRoute object. Envoy Gateway watches those objects and configures Envoy, which handles the requests. The HTTPRoute reference describes its matching, filtering, and backend model.
Build
Install compatible Gateway API CRDs and Envoy Gateway through Helm. Configure the Envoy data-plane LoadBalancer Service for an internet-facing NLB using the selected AWS load-balancer implementation. Keep the controller and the data-plane proxy distinct: customers connect to the proxy.
The following examples use the ecommerce namespace for the Gateway, routes, and backend Services. Create it first. GatewayClass is cluster-scoped.
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: envoy
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ecommerce-gateway
namespace: ecommerce
spec:
gatewayClassName: envoy
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: products-route
namespace: ecommerce
spec:
parentRefs:
- name: ecommerce-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /products
backendRefs:
- name: product-service
port: 8080
The Service must expose Service port 8080; backendRefs.port is not the container's targetPort. These rules preserve /products, so the application must serve that path or you must configure a rewrite.
The HTTP listener is an initial routing exercise. Before exposing credentials or protected traffic, add an HTTPS listener with a valid certificate referenced from a Kubernetes TLS Secret, then redirect or remove HTTP. Manage certificate provisioning declaratively and keep private keys out of Git.
Create equivalent routes for orders and payments. To preserve Architecture A's method restrictions, match GET for products and orders and POST for payments. A path-only route accepts other methods too.
Extend and prove
| Exercise | Evidence to capture |
|---|---|
| Path routing | Each path returns the expected service identifier |
Host routing for orders.example.com
|
Matching host succeeds; another host does not match that route |
| HTTPS listener | Trusted certificate, correct hostname, and protected traffic over HTTPS |
| JWT authorization | Missing/invalid token rejected; valid authorized request succeeds |
| Rate limiting | Controlled load produces gateway 429 responses |
| Cross-namespace backend | Backend reference fails without permission and succeeds with a correctly scoped ReferenceGrant |
| Broken backend | Route status explains the unresolved reference |
| Request mirroring | Test backend receives the copy; client receives the primary response |
Use Envoy's SecurityPolicy for JWT authentication. Use BackendTrafficPolicy rate limiting for the rate-limit exercise. These are Envoy extensions, so their YAML is implementation-specific.
Cross-namespace route attachment and cross-namespace backend references have separate permission mechanisms: the Gateway's allowedRoutes controls attachment; a ReferenceGrant in the backend namespace authorizes the relevant backend reference. Check the installed CRD version before writing that grant.
Mirroring is an extended Gateway API feature: verify controller support. Use a read-only mock endpoint so a copied request cannot trigger a second payment or mutate real data. See the request-mirroring guide.
What this teaches: Gateway API defines routing intent; the implementation supplies the proxy and policies. Standard routes improve portability, while extensions need separate review when switching implementations.
Architecture C: put both together
Now keep external API management in AWS while retaining Kubernetes control over backend traffic.
Customer --HTTPS--> AWS API Gateway HTTP API
|
JWT checks + throttling
|
VPC Link
|
Internal NLB
|
Envoy proxy
|
HTTPRoute backend selection
/ \
product-v1 product-v2
Build
- Change the declarative Envoy data-plane configuration to provision an internal NLB. A scheme change can replace the load balancer; treat it as a migration and verify the public NLB is removed.
- Wait for the NLB listener and healthy Envoy targets.
- Create the HTTP API private integration using that listener ARN and a VPC Link in appropriate private subnets.
- Restore the public route definitions, JWT authorizer, throttling, and CloudWatch access logs.
- Keep backend selection and rollout weights in Kubernetes HTTPRoutes.
- Restrict backend reachability through security groups and network policy where applicable. Verify the effective source and target behavior for the chosen NLB configuration.
- Collect Envoy metrics with Prometheus/Grafana and correlate them with API Gateway logs using a request identifier.
If the internal Envoy listener uses HTTPS, configure API Gateway's backend TLS settings and a certificate hostname that it can validate. Plan frontend and backend TLS separately.
Start with path-only backend routes. When adding host matching, verify which Host header Envoy actually receives through the integration. The customer's public API hostname and the backend integration hostname may differ.
| Decision | Owner in this design |
|---|---|
| Which public method/path is available? | AWS API Gateway |
| Is the caller's access token acceptable? | AWS API Gateway |
| Is a particular customer allowed to access this order? | Application authorization |
| Should products use v1 or v2? | HTTPRoute, implemented by Envoy |
| Which layer rejected a request? | Correlated API Gateway, Envoy, and application telemetry |
These are design choices. Envoy can also enforce authentication; keeping it there provides an additional control if internal callers can reach it. If authorization is delegated to the edge, prevent bypass and never trust arbitrary client-supplied identity headers.
The experiment that makes the distinction clear
Deploy product v1 and v2 behind separate Services and replace the products route with:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: products-route
namespace: ecommerce
spec:
parentRefs:
- name: ecommerce-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /products
backendRefs:
- name: product-v1
port: 8080
weight: 90
- name: product-v2
port: 8080
weight: 10
Collect version counts over a sufficiently large sample at a rate below your throttling target. Expect an approximate distribution, not exactly nine v1 responses followed by one v2 response. Weights are proportional: 9/1 and 90/10 express the same split. See Gateway API traffic splitting.
Change the split through Git to 50/50, then roll back to 100/0. Verify that the public endpoint, API routes, and authorizer configuration remain unchanged.
Record both the observed version distribution and the error/latency metrics. Weighted routing alone does not provide health-based rollout promotion or automatic rollback; those need additional automation.
What this teaches: consumers keep the same API while the platform changes how requests reach application versions.
HTTP API vs REST API: add an API management experiment
AWS API Gateway offers multiple API types. HTTP API is the simpler choice for this project's main path; REST API adds management features worth testing separately.
| Capability | HTTP API | REST API |
|---|---|---|
| HTTP endpoints and private integrations | Yes | Yes |
| Native JWT authorizer | Yes | Yes, in current AWS documentation |
| Cognito-backed authorization | Yes | Yes |
| API keys and per-client usage plans | No | Yes |
| Throttling | Yes | Yes |
| Built-in request validation | No | Yes |
| Response caching | No | Yes |
| Direct AWS WAF integration | No | Yes |
| API Gateway canary release deployments | No | Yes |
| Typical API Gateway request pricing | Lower | Higher |
Check AWS's feature comparison for your requirements. Older tables that say REST APIs cannot use native JWT authorizers are outdated; AWS now documents REST API JWT authorizers. Check Terraform provider support before assuming a newly documented feature is available in your pinned provider.
A private integration describes connectivity to the backend. It does not make the consumer-facing API endpoint private.
For the extra exercise, create two mock API customers:
| Customer | Rate target | Monthly quota target |
|---|---|---|
| Free | 5 requests/second | 1,000 requests |
| Premium | 50 requests/second | 100,000 requests |
Give each an API key, associate the keys with the correct usage plans and deployed stage, and mark the relevant methods as requiring an API key. Configure burst targets explicitly too.
Prove that a key identifies a usage-plan client while separate authorization still controls access. Usage plans are best-effort targets, not hard spending caps or exact entitlements; customers can exceed their configured quotas. See AWS usage-plan guidance.
Organize the implementation by ownership
For a standalone comparison lab, this is a useful logical layout. In a larger project, keep the same boundaries across separate app, platform, and GitOps repositories.
aws-vs-k8s-gateway/
├── applications/
│ ├── product/ # build v1 and v2 images
│ ├── orders/
│ └── payments/ # mock only
├── terraform/
│ ├── modules/
│ │ ├── network/
│ │ ├── eks/
│ │ └── api-management/
│ └── environments/lab/
│ ├── foundation/ # VPC, EKS, IAM
│ └── api-edge/ # APIs, VPC Link, Cognito, logs
├── kubernetes/
│ ├── base/ # workloads and ClusterIP Services
│ ├── architecture-a/ # internal ALB Ingress
│ ├── architecture-b/ # public Envoy Gateway and routes
│ └── architecture-c/ # private Envoy Gateway and routes
├── helm/
│ ├── envoy-gateway-values.yaml
│ └── aws-load-balancer-controller-values.yaml
├── argocd/
│ └── applications.yaml
├── tests/
│ ├── authentication.sh
│ ├── routing.sh
│ ├── canary.sh
│ └── rate-limit.sh
├── docs/
│ ├── decisions/
│ ├── evidence/
│ └── rca/
└── README.md
Terraform owns AWS resources explicitly declared in Terraform. Argo CD owns Kubernetes resources and Helm releases; the load-balancer controller owns the AWS load balancers created from them. Do not also declare those same load balancers in Terraform.
The deployment dependency is:
Terraform foundation
--> Argo CD controllers and workloads
--> Kubernetes-managed load balancer and healthy targets
--> listener ARN passed to Terraform api-edge
--> API Gateway integration
Separate foundation and API-edge roots make that boundary explicit and avoid requiring a listener ARN before the controller has created it. Commit the wiring and discovery procedure; do not rely on an undocumented console copy-and-paste.
Keep one active architecture overlay at a time. Record commands, versions, sanitized outputs, expected behavior, and actual outcomes. A planned proof remains pending until you run it.
Troubleshoot the layer that owns the failure
| Symptom | Start investigating |
|---|---|
API Gateway 401
|
Missing/invalid token, issuer, audience, expiration, signing keys |
Valid token receives 403
|
Required scopes and authorization rules |
429 |
Determine whether API Gateway, Envoy, or the application emitted it |
API Gateway 504
|
Integration timeout, backend latency, network path |
| VPC Link unavailable | Link state, subnet/IP availability, security groups |
| NLB targets unhealthy | Target port, health-check protocol/path, Envoy readiness, security groups |
| HTTPRoute not attached | Parent reference, listener, namespace permissions, Accepted condition |
| Backend reference broken | Service name/port, ReferenceGrant, ResolvedRefs condition |
| Gateway has no address | Controller reconciliation, IAM, subnets, load-balancer events |
Backend 404
|
Forwarded path, named-stage prefix, hostname, listener/route match |
| Canary distribution wrong | Observed generation, route weights, backend identity, sample size, caching |
| Authentication can be bypassed | Remaining public load balancers, alternate Services/listeners, internal access paths |
Read status conditions and events before guessing. Distinguish a request rejected before integration from one rejected by Envoy or the application. Preserve a sanitized request identifier and response source for each deliberate failure.
When would a company choose each?
| Requirement | Reasonable starting point |
|---|---|
| Expose Lambda as an API | AWS API Gateway |
| Route traffic to Kubernetes services | Gateway API with a suitable implementation |
| Split traffic between Kubernetes application versions | Gateway API weighted backends |
| Offer customer-specific API usage plans | API Gateway REST API plus separate authorization |
| Keep an external API stable while Kubernetes routing evolves | Both, when the operating cost is justified |
| Simple Kubernetes app with no separate API management requirement | Gateway API implementation alone may be sufficient |
Envoy is one implementation, not a requirement of Gateway API. EKS Auto Mode also supports Gateway API with ALBs for layer-7 routes and NLBs for supported layer-4 routes. That is a separate deployment option; it is not required for this managed-node-group Envoy lab. Review the Auto Mode feature support before assuming every standard feature maps to an AWS load balancer.
Envoy is useful here because it makes the controller/proxy distinction visible and lets much of the routing configuration carry across environments. Cloud-specific Service settings, certificates, identity, and controller policies still need adaptation.
Budget, timing, and cleanup
Budget 12–18 hours if you already have working EKS, GitOps, identity, and Terraform foundations. Starting those from scratch can take substantially longer.
This is a billed-cloud lab: account for EKS, nodes, load balancers, NAT or other outbound connectivity, public IPv4 addresses, API requests, identity usage, and logs. Check current regional pricing and an account-wide budget alert before provisioning. A budget alert is not a spending cap.
Reuse the cluster across architectures during a session, then destroy disposable infrastructure at the end of the session. Recreate from committed configuration next time.
Clean up in dependency order:
- Stop load tests and remove the API-edge integrations and related resources through their Terraform owner.
- Remove the active Kubernetes exposure resources through GitOps while controllers still run. With automatic self-heal, an imperative deletion can simply recreate them.
- Verify the controller-created ALB/NLB, target groups, and dependent networking resources are gone.
- Remove the remaining applications/controllers, then destroy the Terraform foundation.
- Check for retained logs, persistent volumes, certificates, DNS records, and other billable leftovers. Keep a shared state backend's lifecycle separate.
The final proof is the ability to explain one request end to end: where authentication happened, where a backend was selected, which component handled TLS, and which logs establish the result.
AWS API Gateway primarily manages consumer access to an API. Kubernetes Gateway API primarily describes how traffic reaches Kubernetes applications. Build the three paths, run the failure tests, and that distinction becomes observable behavior.
originally published at https://github.com/nazmur96/devops-learning-journal/blob/main/networking/aws-api-gateway-vs-kubernetes-gateway-api.md
Top comments (0)