API Gateways, Traffic Management & the Edge cheat sheet
104 commands from every lesson of API Gateways, Traffic Management & the Edge, on one page.
Hops and their jobs
DNS | Name → address; GeoDNS can return a nearby or healthy region |
CDN / edge network | Nearest point of presence (anycast); caching; first TLS termination |
WAF + DDoS protection | Block attacks and floods before they reach your network |
Load balancer | Spread connections over gateway replicas; health checks |
API gateway | Routing, authentication, rate limits, retries, timeouts, logs per API |
Service mesh | Service-to-service mTLS, retries, metrics inside the cluster |
Headers that record the journey
X-Forwarded-For | Client IP, plus each proxy that forwarded the request |
X-Forwarded-Proto | Was the original request http or https? |
X-Request-Id / traceparent | One ID across every hop, for logs and traces |
In one line each
Ingress | Original Kubernetes API for HTTP routing into a cluster; frozen, annotations for everything else |
Gateway API | Its successor: role-based, portable, typed routes (HTTP, gRPC, TLS, TCP), traffic splitting |
API gateway | A product for API policy: auth, keys, quotas, transforms, developer portal |
Service mesh | Service-to-service (east-west): mTLS, retries, telemetry, authorization |
Choosing
Expose a few web apps | Gateway API with any conformant implementation |
Public API with keys, plans, quotas | API gateway (managed or self-hosted), often behind or as the Gateway API implementation |
mTLS and policy between all services | Service mesh |
Objects and owners
GatewayClass | Which controller implements gateways of this class (infrastructure provider) |
Gateway | Listeners: port, protocol, hostname, TLS, which namespaces may attach (platform team) |
HTTPRoute / GRPCRoute | Matches, filters, backends (app team) |
ReferenceGrant | Allows a reference into another namespace (owner of the target namespace) |
Debug with status
kubectl get gateway -A | PROGRAMMED column and assigned address |
kubectl describe httproute NAME -n NS | Accepted, ResolvedRefs per parent, with reasons |
kubectl get gateway NAME -n NS -o jsonpath='{.status.listeners}' | attachedRoutes per listener |
Setup
kind create cluster --name gw-lab | Local test cluster |
helm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.10.0 -n envoy-gateway-system --create-namespace | Install Envoy Gateway and the Gateway API CRDs |
kubectl get gateway -A | Is the Gateway PROGRAMMED, with an address? |
kubectl port-forward -n envoy-gateway-system svc/<envoy-svc> 8080:80 | Reach the gateway from your laptop |
Testing
curl -H 'Host: api.example.test' localhost:8080/orders | Send a request for a hostname without DNS |
curl --resolve api.example.test:8443:127.0.0.1 --cacert tls.crt https://api.example.test:8443/ | HTTPS with the right SNI and your own CA |
Ways to authenticate at the edge
API key | Simple shared secret per consumer; easy to leak; good for server-to-server partners |
JWT (OIDC) | Signed token from an identity provider; gateway checks signature, issuer, audience, expiry |
mTLS client certificate | Strong machine identity; certificate lifecycle needed |
External authorization | Gateway asks a service (OPA, custom) for every request; most flexible, adds latency |
JWT checks
Signature | Made with the issuer's private key; verified with its public keys (JWKS) |
iss / aud | Issued by the expected identity provider, for this API |
exp / nbf | Not expired, already valid |
claimToHeaders | Pass verified claims (tenant, plan) to backends as headers |
Kinds of limits
Rate limit | Requests per second or minute; protects capacity from bursts |
Quota | Total usage per day or month; enforces the plan and billing |
Concurrency limit | Requests in flight at once; protects slow backends |
Cost-based limit | Expensive calls count more than cheap ones |
Where counters live
Local | In each gateway replica: fast, no dependency, but N replicas allow N× the limit |
Global | Shared store (Redis via a rate-limit service): accurate across replicas, one more dependency |
Responses
429 Too Many Requests | The client is over its limit |
Retry-After: 38 | Seconds until the client may try again |
x-ratelimit-limit / -remaining / -reset | Limit, what's left, seconds to reset |
Timeouts and retries
HTTPRoute timeouts.request | Total time for the request, including retries |
BackendTrafficPolicy retry.numRetries | How many extra attempts |
retry.retryOn | Which failures to retry (status codes, connect-failure, reset, ...) |
retry.perRetry.timeout / backOff | Limit each attempt; wait between attempts |
Protection
circuitBreaker | Caps on connections, pending and parallel requests to a backend |
healthCheck.passive (outlier detection) | Eject a pod that keeps failing |
Weights 90/10, 0/100 | Canary, then blue/green switch |
RequestMirror filter | Copy traffic to a new version; ignore its responses |
Safe vs breaking changes
Safe (additive) | New endpoint, new optional field in a request, new field in a response, new enum value consumers are told to tolerate |
Breaking | Removed or renamed field or endpoint, changed type, new required request field, changed meaning, stricter validation |
Lifecycle tools
OpenAPI | The contract: paths, schemas, auth, examples |
Spectral (or similar) | Lint the contract against your style rules |
oasdiff (or similar) | Compare two OpenAPI versions in CI; fail on breaking changes |
Deprecation / Sunset headers | Tell clients an endpoint is deprecated and when it will stop working |
Layers
DDoS protection | Absorb floods: network (L3/L4) at the provider edge, HTTP floods (L7) with rate rules |
WAF | Known attack patterns: SQL injection, XSS, path traversal, bad protocol use |
Bot management | Tell humans, good bots and bad bots apart; protect logins and checkouts |
Gateway | Authentication, per-client limits, request size and timeout limits |
Origin protection | Backends accept traffic only from the edge |
Rollout
Detection (count) mode first | Log what would be blocked; tune false positives |
Then block, rule group by rule group | Watch blocked-request dashboards and support tickets |
Steering methods
GeoDNS | Answer by the resolver's location |
Latency-based DNS | Answer with the region measured fastest from that network |
Weighted DNS | Split traffic between regions by percentage |
Failover DNS | Primary while healthy, secondary when not |
Anycast global load balancer | One IP everywhere; the provider steers and fails over in seconds |
Failover checklist
Health check | Deep enough to reflect users (a synthetic request), not just 'port open' |
Capacity | The surviving region can take the extra load |
Data | Replication lag (RPO) known; writes allowed in only one place unless designed otherwise |
Drill | Fail over on purpose regularly; measure RTO |
AWS
CloudFront | CDN and edge TLS, functions at the edge |
AWS WAF / Shield | Web application firewall, rate-based rules / DDoS protection |
Application Load Balancer | L7 load balancing into VPCs and EKS (AWS Load Balancer Controller) |
Amazon API Gateway | Managed API front door: authorizers, usage plans and API keys, throttling |
Global Accelerator | Anycast IPs and fast regional failover |
Azure
Azure Front Door | Global edge: CDN, L7 global load balancing, WAF |
Application Gateway for Containers | L7 load balancer for AKS, Gateway API and Ingress support |
Azure API Management | API gateway + developer portal; policies such as validate-jwt, rate-limit-by-key, quota-by-key |
APIM self-hosted gateway | Run APIM's gateway in your own clusters, managed from Azure |
Envoy response flags
NR | No route matched (404): host or path not configured |
RL | Rate limited (429) |
UT | Upstream request timeout (504) |
URX | Retry limit exceeded (the last attempt's error is returned) |
UH | No healthy upstream (503): no ready endpoints |
UF | Upstream connection failure (503) |
- | No flag: the response came from the backend, or a local reply such as a JWT 401 (see response_code_details) |
Where to look
kubectl get gateway,httproute -A | Status: Accepted, ResolvedRefs, Programmed |
kubectl logs -n envoy-gateway-system deploy/<envoy> -c envoy | Access logs (JSON) with flags and details |
kubectl logs -n envoy-gateway-system deploy/envoy-gateway | Controller: translation errors |
Design outline
1. Context | Users, regions, plans, traffic, SLOs, compliance |
2. Path | Every hop from client to service, with owner and latency budget |
3. Protection | DDoS, WAF rollout, bots, origin protection |
4. Gateway | Implementation, Gateway and route ownership, TLS |
5. Identity | Tokens, keys, claims, what services still check |
6. Limits | Per plan and tenant, local and global, quotas, 429 behaviour |
7. Resilience | Timeouts, retries, circuit breaking, failover |
8. Lifecycle | Versioning, deprecation, portal |
9. Operations | Logs, metrics, traces, alerts, config rollout, upgrades |