Introduction

In earlier parts, we covered setting up GraphQL APIs and querying Neo4j. In this article, we will be applying the Kong API gateway and making it a single point of entry into the AWS EKS cluster.

Pre-requisite

I expect that we already have a running EKS cluster and you have created and applied a .kubeconfig file for your cluster. If not already done, you can follow the official AWS link for creating a cluster and configuring EKS on your local https://docs.aws.amazon.com/eks/latest/userguide/getting-started-console.html.

Kong

It is an open-source API Gateway, built on top of Nginx. It helps us manage control traffic in terms of authentication, rate limiting, Caching, Monitoring, etc. In order to start using Kong in AWS EKS, we first need to install the ingress controller in the cluster. To install the Kong ingress controller we can use Helm charts for that we need to install helm first. Once Helm is installed we just need to execute following commands:

  • helm repo add kong https://charts.konghq.com
  • helm repo update
  • helm install kong/kong

Once the controller is installed we are all set to do all kinds of configurations. l am going to show samples of routing and rate-limiting in this blog.

This is a sample of the YAML file which is used as an ingress resource to configure the ingress controller. In this sample, we are re-routing the traffic from the KONG URL exposed to the world to different microservices based on the path URL. Once configured you can check the configuration by the following command:

  • kubectl describe ingress <ingress_name>

Once ingress routing is configured we can apply different Kong plugin available. In this blog, we will applying rate limit plugin on the microservices. Below is the sample in which we are limiting access to any microservice i.e. an API could not be called more than 2 times in a second. We can also limit based on the number of requests executed in a minute, hour, day, month and year. We can also add limit by request per consumer, IP, and microservice.

After installing Kong it provides us a URL that will be exposed to world for incoming traffic. From there on the controller will check ingress resource configurations and plugins to do re-routing and rate limiting in our case. Architecture diagram is depicted below:

Finally…

In this article, we touch base on the installation and configuration of the Kong API Gateway at a very high level. After following all the blogs it will provide a good start for developing GraphQL API using GraphDB and deploying an API gateway for the application.

References

https://github.com/Kong/kubernetes-ingress-controller

https://konghq.com/kong/