Skip to content

racksync/kong-gateway-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kong Gateway Docker

Kong PostgreSQL Docker License

Production-ready Kong API Gateway deployment with Docker Compose.

Features

  • Authentication - JWT, OAuth2, API keys, and more
  • Rate Limiting - Protect backend services from abuse
  • Traffic Control - Request/response transformations
  • Load Balancing - Distribute traffic across multiple backends
  • Health Checks - Active and passive health monitoring
  • Plugin Ecosystem - 100+ official and community plugins
  • AI Gateway - Native LLM provider integration (Kong 3.9+)

Requirements

  • Docker Engine 20.10+
  • Docker Compose 2.0+
  • 2GB RAM minimum

Quick Start

./setup.sh

The setup script will:

  1. Create .env from default.env if not present
  2. Start PostgreSQL database
  3. Run database migrations
  4. Launch Kong Gateway

Endpoints

Service HTTP HTTPS
Proxy :8000 :8443
Admin API :8001 :8444
Kong Manager :8002 :8445

Verify the installation:

curl http://localhost:8001/status

Configuration

Environment Variables

Copy and edit the environment file:

cp default.env .env
Variable Default Description
KONG_VERSION 3.9 Kong Gateway version
KONG_PG_DATABASE kong PostgreSQL database name
KONG_PG_USER kong PostgreSQL username
KONG_PG_PASSWORD kong PostgreSQL password

Declarative Configuration

Place Kong configuration in config/kong.yaml:

_format_version: "3.0"

services:
  - name: my-service
    url: https://api.example.com
    routes:
      - name: my-route
        paths:
          - /api

Architecture

┌─────────────────┐
│  kong-database  │  PostgreSQL 17 (persistent storage)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ kong-migrations │  Database schema bootstrap
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│      kong       │  Kong Gateway 3.9 (read-only container)
└─────────────────┘

Container dependencies use health check conditions to ensure proper startup ordering.

Operations

Start Services

docker compose up -d

Stop Services

docker compose down

View Logs

docker compose logs -f kong

Backup Database

docker exec kong-database pg_dump -U kong kong > backup.sql

Restore Database

cat backup.sql | docker exec -i kong-database psql -U kong kong

Upgrade

Note: Upgrades may require service downtime. Always backup before upgrading.

  1. Update KONG_VERSION in .env
  2. Run migrations:
docker compose run --rm kong kong migrations up --vv
docker compose run --rm kong kong migrations finish --vv
  1. Restart Kong:
docker compose up -d kong

Security

This deployment implements several security measures:

  • Read-only container filesystem
  • no-new-privileges security option
  • Config directory mounted read-only
  • tmpfs volumes for runtime data

Production Checklist

  • Change default database credentials
  • Enable TLS certificates for all endpoints
  • Restrict Admin API access to trusted networks
  • Configure firewall rules for exposed ports
  • Set up log aggregation and monitoring

License

MIT License - See LICENSE for details.


RACKSYNC

About

Kong API Gateway deployment with Docker Compose

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages