DEV Community

Saviour Gidi
Saviour Gidi

Posted on

Kong Part 1: Installation and First Setup on Ubuntu 18.04

Kong is one of the open source API gateway managers around. A typical use case is when you want to manage(eg. Secure) your API and but you don't have the time to write all those logic inside your API. API Gateway is probably what you need.

API Gateways can do- Rate limiting, securing Your API with Key and tokens, logging and many more.

We would use kong to protect Simple API I wrote with Flask. Watch out for Part 2.

Download and Install

There are several options for installing kong, they include Debian, docker which is very prevalent, kubernates, redhat and even vagrant.

Head over to Kong homepage download kong Debian image from kong website.

Select the one applicable and download.

  • Install Kong

$ sudo apt-get install openssl libpcre3 procps perl #some dependencies

$ sudo dpkg -i kongdeb.deb

Not yet, Kong is only installed. Lets provision persistent database for it.

Provision a database

On your appliance assuming you installed kong on Ubuntu as I did, the default configuration would be available at /etc/kong/kong.cong.default.

  • Make a copy

cp /etc/kong/kong.conf.default /etc/kong/kong.conf

  • Configure the Datastore

Kong support Cassandra and PostgreSQL Database. I am using PostgreSQL over here.

  • Provision the database

CREATE USER kong; CREATE DATABASE kong OWNER kong

  • Update the kong.conf

Scroll to the database section and add the Postgres details.
$ vim /etc/kong/kong.conf and change this section dbname: kong, user=kong, pass=kong2018

Start kong

kong has some commands

$ kong migrations up #runs the database migrations
$ sudo kong start

$ curl -i http://localhost:8001

Imgur

Bonus

$ sudo kong stop #stop kong
$ sudo kong health #kong status

--Happy Hacking--

NB. Watch out for Part 2, where I add the Flask API.

Top comments (2)

Collapse
 
saviour123 profile image
Saviour Gidi

This is just the first blog in the series on API gateways and kong. Stay tune.

Collapse
 
birama profile image
birama • Edited

Hi , nice tuto. waiting for part 2