Cheat Sheets / Kubernetes & Platform

API Gateways, Traffic Management & the Edge cheat sheet

104 commands from every lesson of API Gateways, Traffic Management & the Edge, on one page.

01 · One request, from browser to pod

Hops and their jobs

DNSName → address; GeoDNS can return a nearby or healthy region
CDN / edge networkNearest point of presence (anycast); caching; first TLS termination
WAF + DDoS protectionBlock attacks and floods before they reach your network
Load balancerSpread connections over gateway replicas; health checks
API gatewayRouting, authentication, rate limits, retries, timeouts, logs per API
Service meshService-to-service mTLS, retries, metrics inside the cluster

Headers that record the journey

X-Forwarded-ForClient IP, plus each proxy that forwarded the request
X-Forwarded-ProtoWas the original request http or https?
X-Request-Id / traceparentOne ID across every hop, for logs and traces

02 · Ingress, Gateway API, API gateway, service mesh: who does what

In one line each

IngressOriginal Kubernetes API for HTTP routing into a cluster; frozen, annotations for everything else
Gateway APIIts successor: role-based, portable, typed routes (HTTP, gRPC, TLS, TCP), traffic splitting
API gatewayA product for API policy: auth, keys, quotas, transforms, developer portal
Service meshService-to-service (east-west): mTLS, retries, telemetry, authorization

Choosing

Expose a few web appsGateway API with any conformant implementation
Public API with keys, plans, quotasAPI gateway (managed or self-hosted), often behind or as the Gateway API implementation
mTLS and policy between all servicesService mesh

03 · Gateway API in depth

Objects and owners

GatewayClassWhich controller implements gateways of this class (infrastructure provider)
GatewayListeners: port, protocol, hostname, TLS, which namespaces may attach (platform team)
HTTPRoute / GRPCRouteMatches, filters, backends (app team)
ReferenceGrantAllows a reference into another namespace (owner of the target namespace)

Debug with status

kubectl get gateway -APROGRAMMED column and assigned address
kubectl describe httproute NAME -n NSAccepted, ResolvedRefs per parent, with reasons
kubectl get gateway NAME -n NS -o jsonpath='{.status.listeners}'attachedRoutes per listener

04 · Lab: your first gateway

Setup

kind create cluster --name gw-labLocal test cluster
helm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.10.0 -n envoy-gateway-system --create-namespaceInstall Envoy Gateway and the Gateway API CRDs
kubectl get gateway -AIs the Gateway PROGRAMMED, with an address?
kubectl port-forward -n envoy-gateway-system svc/<envoy-svc> 8080:80Reach the gateway from your laptop

Testing

curl -H 'Host: api.example.test' localhost:8080/ordersSend 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

05 · Authentication at the edge

Ways to authenticate at the edge

API keySimple 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 certificateStrong machine identity; certificate lifecycle needed
External authorizationGateway asks a service (OPA, custom) for every request; most flexible, adds latency

JWT checks

SignatureMade with the issuer's private key; verified with its public keys (JWKS)
iss / audIssued by the expected identity provider, for this API
exp / nbfNot expired, already valid
claimToHeadersPass verified claims (tenant, plan) to backends as headers

06 · Rate limiting and quotas

Kinds of limits

Rate limitRequests per second or minute; protects capacity from bursts
QuotaTotal usage per day or month; enforces the plan and billing
Concurrency limitRequests in flight at once; protects slow backends
Cost-based limitExpensive calls count more than cheap ones

Where counters live

LocalIn each gateway replica: fast, no dependency, but N replicas allow N× the limit
GlobalShared store (Redis via a rate-limit service): accurate across replicas, one more dependency

Responses

429 Too Many RequestsThe client is over its limit
Retry-After: 38Seconds until the client may try again
x-ratelimit-limit / -remaining / -resetLimit, what's left, seconds to reset

07 · Timeouts, retries and traffic management

Timeouts and retries

HTTPRoute timeouts.requestTotal time for the request, including retries
BackendTrafficPolicy retry.numRetriesHow many extra attempts
retry.retryOnWhich failures to retry (status codes, connect-failure, reset, ...)
retry.perRetry.timeout / backOffLimit each attempt; wait between attempts

Protection

circuitBreakerCaps on connections, pending and parallel requests to a backend
healthCheck.passive (outlier detection)Eject a pod that keeps failing
Weights 90/10, 0/100Canary, then blue/green switch
RequestMirror filterCopy traffic to a new version; ignore its responses

08 · The API lifecycle

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
BreakingRemoved or renamed field or endpoint, changed type, new required request field, changed meaning, stricter validation

Lifecycle tools

OpenAPIThe 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 headersTell clients an endpoint is deprecated and when it will stop working

09 · Edge security

Layers

DDoS protectionAbsorb floods: network (L3/L4) at the provider edge, HTTP floods (L7) with rate rules
WAFKnown attack patterns: SQL injection, XSS, path traversal, bad protocol use
Bot managementTell humans, good bots and bad bots apart; protect logins and checkouts
GatewayAuthentication, per-client limits, request size and timeout limits
Origin protectionBackends accept traffic only from the edge

Rollout

Detection (count) mode firstLog what would be blocked; tune false positives
Then block, rule group by rule groupWatch blocked-request dashboards and support tickets

10 · Global traffic and failover

Steering methods

GeoDNSAnswer by the resolver's location
Latency-based DNSAnswer with the region measured fastest from that network
Weighted DNSSplit traffic between regions by percentage
Failover DNSPrimary while healthy, secondary when not
Anycast global load balancerOne IP everywhere; the provider steers and fails over in seconds

Failover checklist

Health checkDeep enough to reflect users (a synthetic request), not just 'port open'
CapacityThe surviving region can take the extra load
DataReplication lag (RPO) known; writes allowed in only one place unless designed otherwise
DrillFail over on purpose regularly; measure RTO

11 · Managed options on AWS and Azure

AWS

CloudFrontCDN and edge TLS, functions at the edge
AWS WAF / ShieldWeb application firewall, rate-based rules / DDoS protection
Application Load BalancerL7 load balancing into VPCs and EKS (AWS Load Balancer Controller)
Amazon API GatewayManaged API front door: authorizers, usage plans and API keys, throttling
Global AcceleratorAnycast IPs and fast regional failover

Azure

Azure Front DoorGlobal edge: CDN, L7 global load balancing, WAF
Application Gateway for ContainersL7 load balancer for AKS, Gateway API and Ingress support
Azure API ManagementAPI gateway + developer portal; policies such as validate-jwt, rate-limit-by-key, quota-by-key
APIM self-hosted gatewayRun APIM's gateway in your own clusters, managed from Azure

12 · Operating gateways

Envoy response flags

NRNo route matched (404): host or path not configured
RLRate limited (429)
UTUpstream request timeout (504)
URXRetry limit exceeded (the last attempt's error is returned)
UHNo healthy upstream (503): no ready endpoints
UFUpstream 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 -AStatus: Accepted, ResolvedRefs, Programmed
kubectl logs -n envoy-gateway-system deploy/<envoy> -c envoyAccess logs (JSON) with flags and details
kubectl logs -n envoy-gateway-system deploy/envoy-gatewayController: translation errors

13 · Capstone: design the edge for a multi-region API

Design outline

1. ContextUsers, regions, plans, traffic, SLOs, compliance
2. PathEvery hop from client to service, with owner and latency budget
3. ProtectionDDoS, WAF rollout, bots, origin protection
4. GatewayImplementation, Gateway and route ownership, TLS
5. IdentityTokens, keys, claims, what services still check
6. LimitsPer plan and tenant, local and global, quotas, 429 behaviour
7. ResilienceTimeouts, retries, circuit breaking, failover
8. LifecycleVersioning, deprecation, portal
9. OperationsLogs, metrics, traces, alerts, config rollout, upgrades