Kong, an open-source API gateway

Kong is an open-source API gateway and a microservices management layer, delivering high performance and reliability. It is a combination of two libraries worth mentioning. One is OpenResty and another one is Nginx. Kong is a wrapper around these two main components. OpenResty is a fully-fledged web platform that integrates Nginx and Lua. Lua is another programming language similar to Go. Kong is written in Lua. We use Kong as a tool for deploying our Go REST services. The main topics we cover are:

  • Installation of Kong and the Kong database
  • Adding our API to Kong
  • Using the plugins
  • Logging in Kong
  • Rate limiting in Kong

Kong needs a database to run. It could be either Cassandra or PostgreSQL. Since we are already familiar with PostgreSQL, we chose it. Where to install them? For illustration, we can install them on our local machine, but there is a drawback; it can screw up our machine. In order to test the setup, we are going to use Docker. Docker can create containerized applications and run them in a predictable, isolated environment.

Using Kong, we can hide our API under a gateway. We can create consumers (clients) for our API. Kong does everything through a REST API. Kong has two kinds of API:

  • Application API (runs on port 8000)
  • Admin API (runs on port 8001)

Using an application API, we can access our web services. An admin API allows us to add/remove APIs under the gateway. We will see these things in more detail in upcoming sections. For more details about Kong, visit https://getkong.org/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.32.1