Next-Generation API Platform
for Modern Architectures

https://konghq.com/

Quickly get it running with Docker

Assuming you have Docker already installed and running, create a docker-compose.yml file:

version: '3.3'

services:
  kong-database:
    image: postgres:9.6
    ports: 
      - 5432:5432
    environment: 
      POSTGRES_USER: kong
      POSTGRES_DB: kong
  kong:
    image: crochik/kong:1.0.2-alpine
    depends_on: 
      - kong-database
    environment: 
      KONG_PG_HOST: kong-database
      KONG_DATABASE: postgres
      KONG_CASSANDRA_CONTACT_POINTS: kong-database
      KONG_PROXY_ACCESS_LOG: /dev/stdout
      KONG_ADMIN_ACCESS_LOG: /dev/stdout
      KONG_PROXY_ERROR_LOG: /dev/stderr
      KONG_ADMIN_ERROR_LOG: /dev/stderr
      KONG_ADMIN_LISTEN: 0.0.0.0:8001, 0.0.0.0:8444 ssl
    ports:
      - 8000:8000
      - 8443:8443
      - 8001:8001
      - 8444:8444

This is going to create the kong container using a slightly modified version of the official 1.0.2-alpine container – it will wait for postgres database server to be ready and will automatically apply the bootstrap migrations, if necessary.

On the folder you have created the docker-compose.yml file, run:

docker-compose up

Add Konga (UI)

Use Ctrl+C to stop docker-compose, add to the bottom of your docker-compose.yml file:

konga:
image: pantsel/konga:next
ports:
- 1337:1337

Note: this will start the :next version of konga. If you want use the last official relase, use :latest instead

and restart docker-compose (now as daemon):

docker-compose up -d

Open your browser and navigate to http://localhost:1337

Create your admin account and then create a connection to the kong running on the other container:

Connect to kong container

After connecting you should be able to use the Konga UI to manage Kong.

Konga dashboard

Using Curl

You can also interact with your kong using curl or any other tool. A basic example:

Create Service

curl -i -X POST \
  --url http://localhost:8001/services/ \
  --data 'name=example-service' \
  --data 'url=http://mockbin.org'

Add Route to new service

curl -i -X POST \
  --url http://localhost:8001/services/example-service/routes \
  --data 'hosts[]=example.com'

Test route

curl -i -X GET \
  --url http://localhost:8000/ \
  --header 'Host: example.com'

References:

Categories: TL;DR

0 Comments

Leave a Reply

Avatar placeholder