API Platform & Lifecycle · Lifecycle and Operations

API Gateways and API Management

What gateways do, deployment models and what not to put in them.

API gateways (Kong, Envoy/Envoy Gateway, NGINX, AWS API Gateway, Apigee, Azure API Management, Tyk) centralize cross-cutting concerns: TLS, authentication (JWT validation, API keys, OAuth introspection), rate limiting and quotas, routing and canary releases, request size limits, CORS, caching, and analytics. API management platforms add developer portals, key provisioning, plans and monetization. Keep business logic out of gateways; use the Kubernetes Gateway API for portable configuration.

Gateway vs service responsibilities

Concern Gateway Service
TLS, request limits, CORS Yes Defense in depth
AuthN (token validation) Yes Verify again or trust mTLS identity
Object-level authorization No Yes
Rate limits / quotas Coarse per client Business-aware limits
Request/response transformation Minimal Domain logic
Routing, canaries Yes No
# Kubernetes Gateway API: route /v1/orders to the orders service with a canary
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: orders }
spec:
  parentRefs: [{ name: public-gateway }]
  rules:
    - matches: [{ path: { type: PathPrefix, value: /v1/orders } }]
      backendRefs:
        - { name: orders-v1, port: 8080, weight: 90 }
        - { name: orders-v1-canary, port: 8080, weight: 10 }

Common pitfalls

  • Business rules in gateway plugins.
  • Gateway as the only authorization layer.
  • Single gateway cluster without redundancy.

Key points

  • Centralize cross-cutting concerns
  • Authorization stays in services
  • Gateway API for portable routing

Further reading: Kubernetes Gateway API

Practice questions

Why shouldn't object-level authorization live in the gateway?

Answer

The gateway doesn't know domain ownership rules or data (e.g., whether order 42 belongs to this user); only the service with the data can decide reliably.

What does API management add beyond a gateway?

Answer

Developer portal, self-service keys and plans, documentation, analytics per consumer, quotas tied to subscription tiers and monetization/billing.

Open in the app to mark lessons complete, take notes and track your progress.