top of page
Recent Posts
  • Writer's pictureassad

Install basic kong api manager on docker

Updated: Oct 3, 2021

Kong is a scalable, open source API Layer (also known as an API Gateway, or API Middleware). Kong runs in front of any RESTful API and is extended through Plugins, which provide extra functionality and services beyond the core platform.


Let get started to run kong on docker.


Create a docker network with kong-net name


docker network create -d bridge  kong-net

Not create a container for postgres. Kong support cassandra and postgre. Use postgre for HA cluster but for simplicity I'm using postgres in this article.


docker run -d --name kong-database --restart=always --network=kong-net -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" -e "POSTGRES_HOST_AUTH_METHOD=trust" postgres:11-alpine

Now it is time to bake the posgres with kong tables and some pre-populated data. For that we need to create a ephemeral whose responsibility is to create tables, do some migration and insert some data. Since this container is ephemeral we must use "--rm" flag at the time of container running command.


docker run --rm --network=kong-net  -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" kong:latest kong migrations bootstrap

No it is time to run the monster (sorry just fun). To run kong which is the main kong engine run following docker run command


docker run -d --name kong --network=kong-net --restart always \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p 80:8000 -p 443:8443 -p 8001:8001 -p 8444:8444 \ 
kong:latest 

Here port 80 is the port of host machine and it is the kong proxy port, which is being used as a reverse proxy and port 8001 is the kong admin port which is use to do administration task.


Your kong is up and running. Now lets do some UI installation so that we can administrate kong using UI. Since here I'm using kong community version so kong community version do not have any UI for administration. So as a solution here I'm using konga a 3rd party tool for kong UI.


Now run konga docker container.


docker run -d -p 1337:1337 --network kong-net --name konga --restart=always -e "NODE_ENV=development" -e "TOKEN_SECRET=iu7YDcPLiZkozQXzZ9kka3Ee1Vid5ZgQ" -e "DB_ADAPTER=postgres" -e "DB_URI=postgresql://kong@kong-database:5432/konga_db" pantsel/konga:latest

Here value of TOKEN_SECRET is any value you choose.


To access konga from you host machine go to you browser and access konga with http://localhost:1337 and there it will ask you to signup admin user. Once you create admin user login into konga and there you need to provide kong admin url to manage it from konga.

in kong admin url put http://kong:8001 and connect it (alternatively you can also give you host ip in kong admin url which is like http://your-host-ip:8001 but please do not do this


More more insight will be coming soon...

422 views0 comments

Recent Posts

See All

Commentaires


Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page