How to install Kong API Gateway, the main gate of web API service
Nowadays, microservices are widely used as a primary software architecture. The classic problem is managing the web API routes in each service that we build. Some run on the same or different ports. The API gateway comes here to help. However, the API Gateway does not only manage routes, but there are several help tools for you to build and integrate the system like a composer composes their orchestra band.
This tutorial will show you how to install Kong API Gateway by the original method on the OS. You are able to install Kong in Docker too, but I’m not talking about the Docker method in this tutorial.
Start installing Kong API Gateway
The first step of all is downloading Kong. In this tutorial, I use Ubuntu 20.04.5 Focal Fossa and Kong API Gateway community edition. For other versions and other operators use this link for checking.
The command for downloading follows above. The first line is a command to download Kong. After the download is completed, use the 2nd command to install Kong. If you encounter an error like the one below, or if you don’t encounter the problem, you can skip this step.
Run the command below to fix the install problem.
After the fixed install, run the install command again. after run the command below to check that Kong was installed completely.
The result shows below after running a command.
In this step, we will install PostgreSQL 14 database run command below follow step line by line.
After installing PostgreSQL had already finished. Run the following command below to open “psql” command terminal.
The result shows below.
Then, Creates a user and database for Kong following the below command. You can change ‘super_secret’ to a password that is super secret for your Kong.
Then, Exit psql terminal. After then, we have to copy the Kong config file from kong.conf.default, name it to kong.conf follows the below command (You can edit on kong.conf.default but I recommend you copy to another file is better.)
After finishing copy step. Open a file with your favorite text edit such as vim nvim nano etc. (In this tutorial I use vim.)
The result after opens the file like below.
Uncomment follow code shows as below config in a config file. For production, you can change proxy_listen as an example. In Kong, the default port is 8000 and 8443 for SSL. For this tutorial, we recommend setting proxy_listen to 80 and 443 as a default.
After finishing modifying the config file next step we need to migrate an initial database. KONG_PASSWORD is setting for super admin strongly recommended by Kong.
After migrations, the result will show below.
And the time to start the Kong API gateway has arrived. run the command below to start Kong.
The result when run command.
To verify Kong was started
Run the command below to check that Kong is working well. If you get a 200 status code that show your Kong run normally.
Congratulation! You have finished installing Kong. The Kong API gateway is a powerful tool. I hope this tutorial will help you. Next article we will talk about “How to implement Konga for Kong API Gateway”. I will write soon.