Step-by-Step Guide to Creating Routes in Kong Community with Konga
Table of contents
- Make Connection in Konga
- Creating Upstream
- Creating Targets
- Create Services
- Create Route
- Create Consumer
- Plugins
- For Service Level
- For Route Level
- For Consumer Level
- Global Plugin
Prerequisites Before Route Creation:
- Route Path
- HTTP Method (Get or Post or Put etc.,)
- Service Name
- Service Path
- Upstream Name
- Upstream targets and Health Check API (if upstream is new).
- Plugins required (Route level or Service level).
- One reference plugin to copy/configure the values of the plugin.
Make Connection in Konga:
Konga is a popular open-source GUI tool designed for managing Kong API Gateway instances. It provides a user-friendly interface for developers and administrators to configure and monitor their APIs, routes, services, and plugins in Kong. Setup konga refer link
Before making any changes in kong, first go to the connection and connect to the respective Kong which we need to make changes.
if the connection is not found then we can create a new connection by giving the kong admin URL http://<kongIP>:<8001 port>.
Note: Always Starts with Upstream configuration :
Creating Upstream :
- Go to the upstream section select Create Upstream and fill in the fields.
- Give the upstream name and other necessary fields
- And give Active health check congifuration with healthcheck path of the microservices and timeout values respectively.
- And we can configure passive health check as well. (Passive Health check : instead of make http request to microservice to check health, i will analyse the ongoing traffic response code and decide microservices are healthy or not)
Creating Targets :
- After creating the upstream, click on Details of Upstream and Click Add Targets.
- And add <IP Address>:<port> of the microservices in the target section.
Once the target is added, the heart symbol should be green which represents the healthy state of the microservice.
Create Services :
Service represents the actual path exposed by the microservice
To Create a Service :
1) Go to the Service section in Konga, and select Create Service
2) Fill the form with service name, service path.
3) And in the host section, if only one microservices is there, then we can directly give the host and port of microservice machine.
4) If multiple host is there, then we can create upstream using above steps, and give upstream name in the host section of service and port can be anything(Default : 80).
5) And then select done.
Create Route :
Routes represent the actual path expose to the customer or client, which then mapped to respective service and then service map to the backend microservices as we configured in host section of service.
To Create Route :
1) Go to the Service Section
2) Select the service that you want to map with routes.
3) Click Add Routes.
4) Then fill the path (after giving path select enter) and select method (POST or GET or PATCH or DELETE or COMBINATION)(after giving path select enter by adding one by one).
5) Then select done.
6) You can view the routes in routes section of konga.
Create Consumer :
What is Consumer : Consumer are the one who is using the apis, which can be customer or application.
To create Consumer :
1) Go to the consumer section.
2) Select Create Consumer and fill in the fields
3) And then You can configure authentication using Credentials section (Basic Auth, Key Auth, HMAC, OAuth2, JWT etc.,)
4) We can form a ACL group for consumers by going to the group section, so that we can create some make routes available to particular group.
Plugins :
What is plugins :
Plugins is used to add additional features to the kong workflow
There are plenty of plugins available,
Frequently used Plugins in IQ Team :
IAM_Auth : iam auth plugin, if we add this plugin in route, the traffic with this route is authenticated by iam service.
BASIC_AUTH : if the route or service configured with basic_auth, the it will validate the route with user and password which is configured in consumer section for respective customer.
RATE_LIMITING : it is used for consumer level, to restrict the consumer for more frequent api hits.
REQUEST_TRANSFORMER : it is used to tranform any request payload
RESPONSE_TRANSFORMER : same like request transformer, but for response modification.
CORS : It is for enable cors if customer hitting the api from browser
To create a plugin:
For Service Level :
1) Go to Respective Service
2) Click on plugin Section
3) Click on Add plugin
4) Select the Plugin which needs to be configured
5) Fill the necessary Fields.
6) Then select ok.
For Route Level :
1) Go to Respective Route
2) Click on plugin Section
3) Click on add plugin
4) Select the Plugin which needs to be configured
5) Fill the neccessary Fields.
6) Then select ok.
For Consumer Level :
1) Go to Respective Consumer
2) Click on plugin Section
3) Click on add plugin
4) Select the Plugin which needs to be configured
5) Fill the neccessary Fields.
6) Then select ok.
Global Plugin :
1) Go to plugin section
2) And create plugin without service or route or consumer, then it will act as global plugin, which will apply to all routes and services.
3) Be carefull while configure global plugin, as it may cause serious issues if wrongly configured.