API Gateway Choice: Kong vs Gravitee
Decide between Kong (programmable DB-less API gateway) and Gravitee (full API management with developer portal, plans, and subscriptions).
TL;DR
Use Nginx/Ingress for TLS termination and volumetric IP limits, and put one API gateway behind it for auth, consumer quotas, and transformations. Pick Kong (DB-less + decK/KIC) for fast, GitOps-managed internal/partner APIs; pick Gravitee APIM when APIs are external products needing a developer portal, tiered plans, and subscription workflows.
Context
An edge reverse proxy (Nginx) routes hosts and paths, but lacks consumer identity, per-client quotas, API key lifecycle, and developer onboarding. An API gateway fills that gap—provided authentication happens in one place only.
Comparison
| Dimension | Kong Gateway (DB-less) | Gravitee APIM |
|---|---|---|
| Sweet spot | Programmable L7 proxy & GitOps CRDs | Full API Management (portal + plans + billing) |
| Config source of truth | Git (kong.yaml via decK or KIC CRDs) | Management API + MongoDB/JDBC (or Gravitee K8s Operator) |
| Multi-tier partner plans | Manual per-consumer plugins | Built-in Plans (STAGING → PUBLISHED → DEPRECATED) & subscriptions |
| Plugin execution | Priority-ordered Lua/Go plugins (cors before auth) | Platform → API → Plan flows with Expression Language |
| Zone isolation | Separate gateway deployments / namespaces | Sharding tags routing APIs to DMZ vs internal gateways |
Decision criteria
- Internal/GitOps-first APIs → Kong: DB-less Kong needs no database, syncs cleanly with Argo CD or
decK diff/sync, and keeps every proxy pod stateless (using Redis only for distributed rate-limit counters withfault_tolerant: true). - External API product / partner portal → Gravitee: If third-party partners browse docs, subscribe to Bronze/Gold plans, and await approval workflows, Gravitee's portal and OpenAPI
request-validationpolicy avoid building a portal from scratch.
Gotchas
- Default
retries: 5in Kong: On non-idempotent endpoints (payments, orders), setretries: 0so a slow upstream timeout never triggers a duplicate write. - Exposing Kong's Admin API (
8001/8444): Keep the Admin API blocked byNetworkPolicyand unreachable off-cluster; use DB-less GitOps instead. - Plugin order (
corsvsauth): Always verify CORS runs before JWT/key-auth so browserOPTIONSpreflights are not rejected with401. - Save vs Deploy in Gravitee: Saving an API in Gravitee does not push it to gateways until it is deployed; automate both in CI via the Kubernetes Operator.
Production checklist
- Authentication (JWT/OIDC/mTLS) is enforced at the API gateway only, never duplicated at the edge proxy.
- Non-idempotent routes explicitly set
retries: 0. - Distributed rate limiting uses Redis with
fault_tolerant: trueso a Redis blip does not take down APIs. - Gateway config lives in Git (KIC CRDs,
decK, or Gravitee Operator), not manual UI/Admin API edits.
Check yourself
Check Yourself
1. A web app works with `curl` through Kong, but browser requests fail on `OPTIONS` preflight with HTTP 401. What is the usual cause?
2. Why should you set `retries: 0` on a payment creation route in Kong?
Sources
Related Notes
Nginx Edge & Reverse Proxy
Production Nginx patterns—graceful reloads, upstream keepalive pools, proxy_pass trailing-slash rules, security headers, rate limiting, and 499/502/504 triage.
Vault Secrets: Dynamic Credentials & Leases
How HashiCorp Vault replaces static passwords with short-lived, leased credentials, PKI certificates, and Transit encryption—plus seal/unseal and Raft backup rules.