KONG - API Gateway Management
KONG API Gateway is a cloud agnostic and cloud-native, simple to use API Gateway management tool.
With more and more organisations moving towards microservice architecture and splitting their monolith, (Not you Prime!)
There are few things every service needs to take care of.
- Authentication/Authorization
- API Administration
- Audit and Security
- Routing and Control
- Monitoring
- Logging
- Caching
When you start implementing these requirements, it may be easy to embed that as part of the service and as the number of services increases, there will be a constant copy/paste of code, constant refactoring, and continous changes to services.
KONG takes care of this heavy lifting and provides the information required by the service.
Setting up
Setting up KONG in your local is very simple. I have come up with a repo to set kong in your local and also onboard a sample API into KONG.
Pre-requisite
- Docker
- Brew
Setup
Setting up KONG in your local is simple. We will use one single command to setup a PostgreSQL DB, A Kong Instance and a sample node API app. Just run the command and relax!
Step 1
git clone https://github.com/sanjeevkumarraob/local-kong.gitcd local-kong
Step 2
If you have an enterprise kong license, copy the license.json to local-kong
folder (repo base path). Then run,
./setup-local.sh
Step 3
Gotcha! No more steps. Just sit and relax!
Verify
Now open a browser and goto http://localhost:8002
which is the admin portal for KONG.
You should be able to see there are two services available in the default workspace. The services got onboarded to kong using the kong.yaml
file and you can check there are multiple endpoints available for these services.
To check the mockbin service, open a browser and go to http://localhost:8000/mock
for mockbin service.
Similarly for node-hello service endpoints,
http://localhost:8000/profile
- for GET profile requesthttp://localhost:8000/posts
- for GET posts requesthttp://localhost:8000/comments
- for GET posts request
You can check more http methods (GET, POST, PUT, DELETE) using the same endpoints. check json-server more info.
Postman verification
A sample postman collection has been added in docs
folder to test the sample node-hello service. This will route all the request through kong.
Add your service
The local setup of kong is a stripped down version of enterprise solution. It doesn't have authentication/authorization enabled locally. You can onboard APIs which doesn't need authentication or a dummy stub JWT can be used in your local application testing.
To add your service, just add another block or modify the existing host block in the kong.yaml
file.
Then run,
./setup-local.sh