Kong API Gateway is one of my favorite API Gateway when come to the microservice architecture and also RESTful API.
What is Kong?
Kong is a widely adopted, open source API Gateway, written in Lua. It runs on top of Nginx, leveraging the OpenResty framework and provides a simple RESTful API that can be used to provision your infrastructure in a dynamic way.
Kong able to help to manage the redundant features that require by all REST API in a single place such as the security, caching, logging. It’s also provide the extension for user to write the own plugin using Lua to fit even better for a special use case.
What is Konga?
Konga is a fully featured open source, multi-user GUI, that makes the hard task of managing multiple Kong installations a breeze.
It can be integrated with some of the most popular databases out of the box and provides the visual tools you need to better understand and maintain your architecture.
Konga come with a lot of useful features where you can fully manage all the object in the Kong Gateway, not only that, they support the backup, restore, migrate and manage multiple Kong node in a single place. It’s also come with the features rich monitoring tools and email notification once any of your API or Node fail on the heart beat checking.
For this demonstration, I will use the docker container to easily install and run the Kong API Gateway, there are more than 1 way to installing the Kong in your infrastructure where you can find the method here:
1. To start the installation, you need to pre-installed the docker container in your server. Once the docker is working in your server, than you can continue to the following step which create a special network for the docker
$ docker network create kong-net
2. Once the network created, you can continue to installing the postgres database, Kong can also support the cassandra database as well.
$ docker run -d --name kong-database \ --network=kong-net \ -p 5432:5432 \ -e “POSTGRES_USER=kong” \ -e “POSTGRES_DB=kong” \ postgres:9.6
3. Let us now prepare our database by starting an ephemeral Kong container which will run the appropriate migrations and die!
$ docker run --rm \ --network=kong-net \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=kong-database" \ kong:latest kong migrations up
4. Everything is now set and ready to start Kong!
$ docker run -d --name kong \ --network=kong-net \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=kong-database" \ -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \ -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \ -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \ -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \ -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ -p 8000:8000 \ -p 8443:8443 \ -p 8001:8001 \ -p 8444:8444 \ kong:latest
5. Once everything is ready, the Kong API Gateway is ready to use, you may test the gateway my trigger to the port 8000 and also 8001
$ curl -i http://localhost:8001/
$ curl -i http://localhost:8000/
To installing and run the Konga, just run the following script to pull the docker image as well as start it in the same network with Kong server. The following script will only store all the data of Konga using it’s own internal file system.
$ docker run -d -p 1337:1337 \ --network=kong-net \ --name konga \ -v /var/data/kongadata:/app/kongadata \ -e "NODE_ENV=production" \ pantsel/konga
Alternatively, Konga also support few of the databases such as Mongodb, MySQL, Postgres as well as SQL Server which you can use to store the data out from the default file system.
You may preparing the database migration before start the Konga
$ docker run --rm \ --network=kong-net \ pantsel/konga -c prepare -a postgres -u postgresql://[email protected]:5432/konga_db
After the database is ready, you may proceed to start the Konga by supply the DB driver as well as the DB connection string
$ docker run -p 1337:1337 \ --network=kong-net \ -e "DB_ADAPTER=postgres" \ -e "DB_HOST=kong-database" \ -e "DB_USER=kong" \ -e "DB_DATABASE=konga_db" \ -e "KONGA_HOOK_TIMEOUT=120000" \ -e "NODE_ENV=production" \ --name konga \ pantsel/konga
You may refer here for the detail installation of Kongahttps://github.com/pantsel/konga
If you are even more lazy, here is the docker compose file you can just make the whole thing workhttps://gist.github.com/pantsel/73d949774bd8e917bfd3d9745d71febf
Once Konga is up and running, than you should be able to access to the Konga admin page at
http://<you server IP>:1337
Login with the following default credential:
Username: admin Password: adminadminadmin
At this point, you can manually create a connection to Kong’s admin API but, since we deployed everything using the “default” way, Konga has already created that initial connection for us.
If you open the
connections page, you’ll notice that a connection to the previously created Kong instace is already there but not yet active.
activate button. If everything is set up properly, Konga will connect to Kong and the interface will be filled with all kinds of coolness.
Up to now, you are good to go to start using the Konga GUI to manage your API gateway, but please remember to always change your password before you proceed to the next step.
Although there are a lot more free and paid tools available such as AWS API Gateway and so on, but I still more prefer with the Kong API Gateway. Not only the functionality, but also the stability that provided. Even though the CE version only come with CLI, but you still can easily get the free GUI from the GitHub or Docker Hub.