Overview
This template provides a production‑ready Kong stack as a Monk runnable. You can:- Run it directly to get a managed Kong API gateway with PostgreSQL backend
- Inherit it in your own runnable to seamlessly add API management to your microservices
What this template manages
- Kong Gateway container (
kongimage, configurable tag) - Konga Admin GUI (web interface for managing Kong)
- PostgreSQL database (configuration and state storage)
- Automatic database migrations on startup
- Network services for proxy (8000) and admin (1337)
- Persistent volumes for database storage
Quick start (run directly)
- Load templates
- Run Kong stack with defaults
- Customize credentials (recommended via inheritance)
variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
- Preferred: inherit and replace variables with
secret("...")as shown below. - Alternative: fork/clone and edit the
variablesinkong/kong.yml, thenmonk load MANIFESTand run.
- Kong Proxy:
http://localhost:8000 - Konga Admin GUI:
http://localhost:1337
Configuration
Key variables you can customize in this template: Kong Gateway (kong/kong-common):
kong/db):
${monk-volume-path}/kong/db_data on the host.
Use by inheritance (recommended for apps)
Inherit the Kong stack in your application and connect your services through the API gateway. Example:Ports and connectivity
Services exposed bykong/kong:
kong-app: TCP port8000- Kong proxy (main API gateway entry point)konga: TCP port1337- Konga admin GUI (host-port mapped)
kong/db:
kong-db: TCP port5432- PostgreSQL database
connection-hostname("\<connection-name>") to resolve service hosts. Kong automatically connects to the database via the db connection.
Persistence and configuration
- Database data path:
${monk-volume-path}/kong/db_data:/var/lib/postgresql/data - Kong runs migrations automatically on startup via the
kong-migrations-upcontainer - Configure Kong declaratively via
/opt/kong/kong.yaml(mounted inkong-appcontainer) - For dynamic configuration, use the Admin API or Konga GUI after startup
Features
- API Gateway: Single entry point for routing requests to microservices
- Load Balancing: Distribute traffic across multiple service instances
- Authentication & Authorization: OAuth2, JWT, Basic Auth, API keys, and more
- Rate Limiting: Protect services from overload with request quotas
- Service Discovery: Dynamic upstream service registration
- Plugin Ecosystem: 50+ official plugins (logging, monitoring, transformations)
- Admin GUI: Konga web interface for visual management
- Declarative Configuration: Define routes and services as code
Related templates
- Combine with monitoring tools (
prometheus-grafana/) for observability and metrics - Integrate with service meshes for advanced traffic management
- See other templates in this repository for complementary services
Troubleshooting
- If database migrations fail, check that PostgreSQL is fully started and accessible. The
kong/kongrunnable waits up to 30 seconds forkong/dbvia thedepends.wait-forclause. - Ensure database credentials match between Kong and PostgreSQL configurations.
- If ports 8000 or 1337 are already in use, modify the service port mappings in your inherited runnable.
- Check logs:
- Verify PostgreSQL is ready: