Microservices with Kong API Gateway — Part 1 (Install Kong)
This tutorial will tell you the very basic in how to install Kong on Docker
What is Micro service
Very hard to find a simple and single answer and many try to define on their own terms, but I can say as Micro service is architecture style a suite of independently deployable, small, modular services in which each service runs a unique process and communicates through a well-defined, lightweight mechanism to serve a business goal.
What is Kong
Is the world’s most popular open source API gateway, built for multi-cloud and hybrid, and optimized for microservices and distributed architectures
Installing Kong with Docker
For latest updates on Kong install can be found here
- Create docker network
We are going to create a custom docker network so all the docker containers discover and communicate with each other
$ docker network create kong-micro
2. Create a database for Kong using PostgreSQL
$docker run -d — name kong-database — network=kong-micro -p 5432:5432 -e “POSTGRES_USER=kong” -e “POSTGRES_DB=kong” -e “POSTGRES_PASSWORD=kong” postgres:9.6
3. Prepare the database
Run the migrations with an ephemeral Kong container
$docker run — rm — network=kong-micro -e “KONG_DATABASE=postgres” -e “KONG_PG_HOST=kong-database” -e “KONG_PG_PASSWORD=kong” -e “KONG_CASSANDRA_CONTACT_POINTS=kong-database” kong:latest kong migrations bootstrap
4. Start Kong
If you done all the steps correctly your ready to start Kong
$docker run -d — name kong — network=kong-micro -e “KONG_DATABASE=postgres” -e “KONG_PG_HOST=kong-database” -e “KONG_PG_PASSWORD=kong” -e “KONG_CASSANDRA_CONTACT_POINTS=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 127.0.0.1:8001:8001 -p 127.0.0.1:8444:8444 kong:latest
After that, we have two running docker containers, one for PostgreSQL DB and another for kong instance.
5.Test Kong
$ curl -i http://localhost:8001/ — Kong’s admin API
In Next section we will create and deploy simple Spring boot application to Kong.
….. NEXT