This repository contains practical examples demonstrating various features and use cases of Kong API Gateway.
Each example is self-contained and includes:
- Complete configuration files
- Docker Compose setup
- Detailed documentation
- Step-by-step instructions
- Testing procedures
General requirements for all examples:
- Docker
- Docker Compose
- curl (for testing)
- Kong Enterprise license (for enterprise features)
Demonstrates how to use Kong's Request Callout plugin to enrich API requests with data from multiple backend services.
Key Features:
- Sequential API calls
- Request/response transformation
- Mock backend services
- Data enrichment patterns
Technologies:
- Kong Request Callout plugin
- Kong Mocking plugin
- OpenAPI specifications
Shows how to use Kong API Gateway to mediate between HTTP and Kafka protocols.
Key Features:
- HTTP to Kafka message production
- Kafka to HTTP consumption
- Server-Sent Events (SSE) streaming
- Synchronous and asynchronous patterns
Technologies:
- Kong Kafka Upstream plugin
- Kong Kafka Consumer plugin
- Apache Kafka
- Server-Sent Events
Demonstrates how to consume Kafka messages via Server-Sent Events (SSE) with OpenID Connect (OIDC) authentication.
Key Features:
- Kafka message consumption via SSE
- OIDC authentication integration
- Keycloak for identity management
Technologies:
- Kong Kafka Consumer plugin
- Kong OIDC plugin
- Apache Kafka
- Server-Sent Events
Demonstrates how to use Kong Gateway as an event gateway with Kafka integration, including schema validation using a Schema Registry.
Key Features:
- Kafka message production with schema validation
- Multiple consumption patterns (REST and SSE)
- Schema Registry integration
- Avro and JSON schema support
Technologies:
- Kong Kafka plugins
- Apache Kafka
- Apicurio Schema Registry (Confluent-compatible)
- Avro schemas
- Clone this repository:
git clone https://github.com/your-username/kong-examples.git
cd kong-examples
- Set up your Kong Enterprise license:
export KONG_LICENSE_DATA='{"license":{"version":1,...}}'
- Choose an example and follow its specific README instructions.
kong-examples/
├── README.md
├── request-callout/
│ ├── README.md
│ ├── docker-compose.yaml
│ ├── kong-config/
│ │ └── kong.yaml
│ └── mock-api.yaml
├── kafka-http-mediation/
│ ├── README.md
│ ├── docker-compose.yaml
│ └── kong-config/
│ └── kong.yaml
├── kafka-sse-with-auth/
│ ├── README.md
│ ├── docker-compose.yaml
│ ├── kong-config/
│ │ └── kong.yaml
│ └── realm-export.json
└── kafka-schema-validation/
├── README.md
├── docker-compose.yaml
├── docker-compose.ee.yaml
├── kong-config/
│ └── kong.yaml
├── avro-schema.json
└── json-schema.json
Contributions are welcome! Please feel free to submit a Pull Request.
When adding a new example:
- Create a new directory with a descriptive name
- Include a comprehensive README
- Provide all necessary configuration files
- Add the example to this main README
- Ensure all code is well-documented
This project is licensed under the Apache 2.0 License.