Kong API Gateway Guide

Khimananda Oli 7 min read Virtualization
Kong API Gateway Guide

By Khimananda Oli | Last reviewed: August 2026

Managing traffic across dozens of microservices without a centralized control plane quickly leads to duplicated auth logic, inconsistent rate limits, and blind spots in observability. This Kong API Gateway guide provides the operational blueprint for deploying Kong as a high-performance, cloud-native traffic controller that enforces policy at the edge while keeping your application code clean. Whether you are running on bare metal or orchestrating with Kubernetes ingress controllers, getting the foundational architecture right prevents costly rework later.

External ClientsKong GatewayRate Limit / Auth PluginsProxy Core (Nginx)Declarative Config (DB-less)Auth ServiceOrder APIInventory APITraffic flows left-to-right; policies enforced at proxy layer
Kong API Gateway guide architecture: centralized policy enforcement between clients and upstream microservices

How do you install and configure Kong API Gateway in DB-less mode?

In 2026, DB-less (declarative) mode is the standard for production Kong deployments. It removes the database as a single point of failure, enables GitOps workflows, and makes configuration auditable. Instead of mutating state via the Admin API, you define your entire gateway topology in a single kong.yml file and load it at startup.

Step-by-step DB-less setup with Docker

  1. Create a declarative configuration file named kong.yml:
    _format_version: "3.0"
    services:
      - name: order-service
        url: http://order-api:8080
        routes:
          - name: order-route
            paths:
              - /api/v1/orders
            strip_path: false
    plugins:
      - name: rate-limiting
        config:
          minute: 100
          policy: local
      - name: cors
        config:
          origins:
            - https://app.example.com
          methods:
            - GET
            - POST
  2. Run Kong with environment variables pointing to this file:
    docker run -d --name kong-dbless \
      -e "KONG_DATABASE=off" \
      -e "KONG_DECLARATIVE_CONFIG=/kong/kong.yml" \
      -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
      -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
      -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
      -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
      -e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
      -v $(pwd)/kong.yml:/kong/kong.yml:ro \
      -p 8000:8000 \
      -p 8001:8001 \
      kong:3.9
  3. Validate the configuration before reloading in production using kong reload -c /kong/kong.yml or the CI lint step. Invalid YAML causes Kong to reject the reload entirely, preserving the last known good state.

A common mistake is enabling the Admin API on a public interface. In DB-less mode, the Admin API is read-only for most operations but still exposes sensitive configuration. Always bind it to localhost or a private management network, and never expose port 8001 to the internet. For teams managing multiple environments, store kong.yml in version control and deploy via CI/CD pipelines rather than manual edits.

Which Kong plugins are essential for production security and reliability?

Kong ships with over 100 plugins, but most production deployments rely on a core set that addresses authentication, traffic control, and observability. Installing too many plugins adds latency; each plugin executes in the request path. Audit your plugin list quarterly and remove anything unused.

PluginPurposeKey ConfigurationPerformance Impact
key-auth / jwtConsumer authenticationkey_names, hide_credentialsLow (<1ms)
rate-limitingPrevent abuse and ensure fair usageminute, policy: redis for multi-nodeMedium (Redis roundtrip)
corsCross-origin resource sharingorigins, credentialsNegligible
prometheusMetrics export for monitoringper_consumer: trueLow
opentelemetryDistributed tracing propagationendpoint, header_typeLow-Medium
ip-restrictionNetwork-level access controlallow, deny CIDRsNegligible

For authentication, prefer JWT validation at the gateway over forwarding tokens to every backend service. This offloads cryptographic verification from your application code. When using rate-limiting across multiple Kong nodes, always set policy: redis with a dedicated Redis cluster; the local policy only tracks limits per-node and allows N× the intended rate. Pair rate limiting with the Prometheus Alertmanager to trigger alerts when consumers consistently hit their quotas, which often signals abuse or misconfigured clients.

HTTP RequestJWT PluginValidate tokenSet consumerRate LimitCheck Redis counter429 if exceededOpenTelemetryInject trace headersExport spanUpstreamPlugins execute sequentially; failures short-circuit the chain
Kong plugin execution flow: sequential processing where each plugin can accept, modify, or reject requests

How does Kong API Gateway integrate with Kubernetes ingress?

On Kubernetes, Kong operates as an Ingress Controller that translates native Ingress and Gateway API resources into its internal proxy configuration. This eliminates the need to maintain separate kong.yml files; your routing rules live alongside your application manifests. The Kong Ingress Controller (KIC) watches the Kubernetes API and pushes configuration to Kong pods automatically.

Deploying Kong with Helm on Kubernetes

helm repo add kong https://charts.konghq.com
helm repo update

helm install kong kong/kong \
  --namespace kong-system --create-namespace \
  --set ingressController.enabled=true \
  --set env.database=off \
  --set proxy.type=LoadBalancer \
  --set proxy.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-type"=nlb \
  --set autoscaling.enabled=true \
  --set autoscaling.minReplicas=3 \
  --set autoscaling.maxReplicas=10

Always enable autoscaling for Kong pods in production. Traffic spikes hit the gateway first, and insufficient replicas cause cascading failures across all downstream services. Set resource requests and limits explicitly; Kong's memory usage scales with the number of routes and plugins. Monitor pod restarts and OOMKills via Prometheus metrics to right-size these values.

For teams adopting the Gateway API (the successor to Ingress), Kong 3.x supports Gateway, HTTPRoute, and TLSRoute resources natively. This provides richer expressiveness for header-based routing, weight-based traffic splitting, and cross-namespace references without annotations. Migrate gradually; both Ingress and Gateway API resources can coexist during transition.

What are the operational best practices for monitoring and scaling Kong?

Kong exposes Prometheus metrics at /metrics by default when the prometheus plugin is enabled globally. Key metrics to alert on include kong_http_status (error rates by status code), kong_latency_bucket (proxy latency percentiles), and kong_db_reachable (database connectivity for DB-backed modes). High 4xx rates usually indicate client misconfiguration; high 5xx rates signal upstream failures or gateway resource exhaustion.

  • Enable structured logging: Configure KONG_LOG_LEVEL=info and use JSON log format for machine parsing. Ship logs to your centralized stack following structured logging best practices to correlate gateway events with backend traces.
  • Health checks are mandatory: Configure active health checks for every upstream. Passive health checks alone detect failures only after clients experience them. Active probes catch degraded backends before traffic reaches them.
  • Separate data and control planes: In large deployments, run dedicated Kong nodes for the Admin API and config distribution separately from proxy nodes. This prevents management operations from impacting request latency.
  • Test plugin combinations: Some plugins interact unexpectedly. Always benchmark your specific plugin chain under realistic load before production rollout. A rate-limiter plus JWT plus OpenTelemetry may add 15–25ms p99 latency; know this number.
  • Version pinning: Kong releases frequently. Pin your Docker image tag to a specific minor version (e.g., kong:3.9.2) and test upgrades in staging. Breaking changes in plugin schemas between major versions are common.
DB-less Mode (Recommended)✓ GitOps-friendly, version-controlled config✓ No database dependency or failover risk✓ Instant horizontal scaling, no shared state⚠ No runtime Admin API writesDatabase-Backed Mode✓ Dynamic Admin API configuration⚠ PostgreSQL/Cassandra HA required⚠ Config drift risk without IaC discipline⚠ Database becomes scaling bottleneckChoose DB-less for new deployments; migrate legacy DB-backed setups incrementally
Kong deployment modes comparison: DB-less offers simplicity and GitOps alignment; database-backed suits dynamic legacy workflows

Implementing Kong API Gateway Guide Recommendations in Production

This Kong API Gateway guide has covered the critical decisions: DB-less declarative configuration, essential plugin selection, Kubernetes integration, and operational monitoring. Start with DB-less mode unless you have a specific requirement for runtime Admin API mutations. Treat your gateway configuration as code, review it in pull requests, and automate validation in CI. If you are designing a new microservices platform or migrating from a legacy gateway and need architecture review or hands-on implementation support, reach out to discuss your infrastructure needs.

Frequently Asked Questions

Kong manages, secures, and extends microservices traffic. It handles authentication, rate limiting, logging, and protocol translation between clients and backend services using a plugin architecture.

Use the official Helm chart with kubectl apply or helm install kong/kong. Configure values.yaml for database mode, ingress controller settings, and resource limits matching your cluster capacity and Kong version 3.9 requirements.

Yes, Kong Gateway OSS is open source and free. Enterprise features like RBAC, audit logs, and advanced plugins require a paid license or Kong Konnect subscription for production support.

Choose Kong for rich plugin ecosystems and multi-protocol support beyond HTTP. Pick NGINX Ingress for simpler routing needs where lightweight performance matters more than extensibility or advanced gateway policies.

Enable the rate-limiting plugin globally or per route via Admin API or declarative config. Set limits by consumer, IP, or service using second, minute, hour, day, month, or year windows with Redis backing for distributed accuracy.

Yes. Configure certificates in Kong's certificate store and bind them to SNI or wildcard domains. Kong terminates TLS before proxying to upstreams, supporting mTLS and automatic renewal via ACME plugin integration.

PostgreSQL and Cassandra are supported for traditional deployments. DB-less mode uses declarative YAML configs loaded at startup, eliminating database dependencies entirely for immutable infrastructure patterns common in GitOps workflows.

Enable request tracing headers and check Kong logs for upstream response times. Profile plugin execution order, reduce unnecessary plugins per route, and verify connection pooling settings against actual backend capacity and network conditions.

Yes. Kong proxies gRPC natively with transcoding plugins for REST-to-gRPC conversion. WebSocket connections pass through transparently when upgrade headers are preserved, requiring no special configuration beyond standard TCP proxy settings.

Kong mitigates top API risks via OpenID Connect, JWT validation, CORS, IP restriction, and schema validation plugins. Combine with WAF plugins and regular security audits to address injection, broken auth, and excessive data exposure vulnerabilities effectively.

Deploy multiple Kong nodes behind a load balancer for high availability. Use health checks and circuit breakers so traffic reroutes automatically. Stateless DB-less mode recovers fastest since nodes reload config without database coordination delays.

Export existing routes and policies into Kong's declarative YAML format. Test in staging with mirrored traffic using shadow mode. Validate responses match before cutover, then decommission legacy systems after monitoring confirms parity.

Yes. Enable the prometheus plugin to expose metrics endpoints. Scrape with Prometheus server and visualize request rates, latencies, error codes, and plugin performance in prebuilt Grafana dashboards maintained by the Kong community.

Admin API provides full programmatic control for automation and CI/CD pipelines. Kong Manager offers visual configuration browsing and basic edits but lacks bulk operations, making it suitable only for inspection and simple troubleshooting tasks.

Upgrade quarterly to stay current with security patches and feature improvements. Always test major version jumps in non-production first, review breaking changes in release notes, and validate plugin compatibility before deploying to live environments.