Skip to content

hashaaamm/Kong-gateway-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kong API Gateway Demo

This demo project demonstrates the usage of Kong API Gateway with multiple microservices.

The project contains six services:

  • Postgres (Kong): Database used by Kong in DB mode.
  • Kong: API Gateway managing requests to the microservices.
  • Reports Service: FastAPI-based microservice for reporting.
  • Results Service: FastAPI-based microservice for results and requires auth
  • Accounts Service: Django-based microservice for user registration and JWT management.
  • Postgres (Accounts): Database used by the Accounts service

Architecture

Architecture Diagram

Prerequisites

  • Docker
  • Docker Compose
  • Kong Deck CLI

Install Deck

brew tap kong/deck
brew install deck

Project Structure

  • config/: Kong configuration files.
  • reports/: FastAPI-based report microservice.
  • results/: FastAPI-based result microservice.
  • accounts_service/: Django-based accounts service.

Docker Setup

Each project contains its own Dockerfile for building the respective service containers. The project also contains a Docker Compose file for orchestrating the services.

Setup

To use this demo, follow these steps:

Start Kong in DB mode with PostgreSQL:

make kong-postgres

Import the configurations:

make kong-import

How to use?

To access Kong admin

Go to http://localhost:8002/

To Register user

curl -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]", "password":"mysecretpassword"}' http://localhost:8000/api/auth/users/

To login / Get token

curl -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]", "password":"mysecretpassword"}' http://localhost:8000/api/auth/jwt/create/

Make a get request to result service which requires auth

curl -H "Authorization: Bearer <your-token-goes-here>" http://localhost:8000/results/

Make a get request to report service which doesn't requires auth

curl -X GET http://localhost:8000/reports/

Kong Features

  • JWT
  • Proxy caching
  • Request transformer
  • Response transformer
  • Request log
  • Cors
  • Ip restriction
  • Rate limiting
  • Request size limiting
  • Lambda functions
  • Log to file/http/Tcp
  • Deck CLI

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published