Introduction

Today, it’s a sun day and I’m pretty happy to write this tutorial to show you how it’s easy to install an API gateway in a Kubernetes cluster.

 

What’s an API gateway?

An API gateway is a programming service in front of an application programming interface (API) which filters the traffic. This front-end service is useful when you have a Microservice architecture pattern.

 

Microservice architecture

Microservice architecture

 

API gateways can be used to limit traffic and enforce security policies. In addition to combining a number of APIs with potentially different interfaces in a unified presentation interface, separating the interface and the API has a number of advantages. When an API contains all the necessary functions, ease of use can be improved by updating the gateway interface. Because the API Gateway is separate, it can be updated while avoiding changes to an API that could result in an unexpected operation. The frontal nature of an API gateway allows the gateway to provide new languages while the hidden APIs remain intact, rather than updating multiple APIs separately.

 

Why using Kong?

 

Kong

 

It’s not just because I’m loving monkeys… In comparaison of other API gateways, Kong offer many advantages:

  • Radically Extensible
  • Multi store (Postgresql or Cassandra)
  • Blazingly Fast
  • Open Source (+17k stars, 110 contributions)
  • Platform Agnostic
  • Cloud Native
  • RESTful APIs
  • Many plugins

 

Kong infrastructure example

Kong infrastructure example

 

In this article, we’ll use the open source Community Edition.

 

It’s time!

To be installed, Kong just need a datastore initialized. In this article, I’ll use PostgreSQL because this service will be shared with micro services (later).

 

In first, check your cluster status.

 

Clone this official kong-dist-kubernetes repository.

 

Create the PostgreSQL service.

If you don’t my PostgreSQL constraint, prefer Cassandra datastore because it’s better solution for scalability.

 

Now, create the ephemeral migration job.

 

When the migration is done, you can remove it.

 

If all pods are running, you can now install Kong.

 

You should have a similar output if you check your pods status:

 

Ok, but how to check if the service really runs?

If like me your have a remote remote cluster proxify your connection.

 

Open your browser add copy and paste this url.

 

Kong should respond you with a beautiful JSON output:

 

Sources

 

 

Leave a comment