Navigate back to the homepage

Designing microservices with the Kong API gateway

Julio César
January 14th, 2020 · 2 min read

Microservices are a big part of modern web applications, been able to ship small functionalities to the cloud is handy because it allows fast delivery, enables serverless on our solutions, and well, it has a lot of potential for optimization. Kong is an open source API gateway that will help us with that.

One key feature about Kong is the built-in RESTful API we have to manage our configurations and resources, so we don’t have to manually create messy configuration files, another important thing to notice is the ability to integrate or develop plugins on top of it, like for example an admin UI like Konga .

That said, how do we integrate the Kong API gateway with microservices ?

What is an API gateway?

First, let’s briefly define what an API gateway is. An API gateway is a front door to the client, any request from it will be processed and transformed then it will be routed to your upstream service (your API). It’s a really simple architecture, but it could scale for the best, for example we can add a load balancer, traffic control, analytics, as well as having a VPC to protect internal services from the public cloud and so on.

kong arch

A practical example

A cool project that makes sense to integrate with will be an OAuth server, said for example you want to have an identity provider and access management, which implies, at least most of the time, the requirement to expose identity validation for an user in the frontend, and also talk to any service we have internally on our backend to perform a transaction on behalf of that user, thus from a microservices perspective it will make a lot of sense to consider using a Proxy or an API gateway to design reliable solutions since we will be having a diversity of microservices that need some sort of centralization for common functionalities like on this example: authorization and authentication.

Maybe in the near future I will write something about that using a really cool open source project like Keycloak.

For now, I think with that definition and example it’s so far cover the basics of the operating principle for this kind of solution. If you want more information about an API gateway and Kong in particular go to the Documentation for Kong.

Installing Kong API gateway

Now, let’s start working with it. We are going to create a docker compose file based on the official docker installation for simplicity.

Just run docker-compose up -d and you will have it all spinning up.

Initial configuration

Desining a microservice

Conclusions

Subscribe to the Newsletter

Subscribe to get my latest content by email.

Prokopê – Julio César
Link to $https://twitter.com/@juliocesar_ioLink to $https://github.com/juliocesar-ioLink to $https://www.linkedin.com/in/juliocesar-io