install-kong-using-docker-compose

Pre-requisites

Before you start, make sure you have the proper pre-requisites - Training Exercises Prequisites

Community Edition
Enterprise Edition
Kong version: 0.11.X

Scenario

You are new to Kong and want to get familiar with its features without worrying about all the components that you need to install.

In this exercise, you will install Kong using Docker Compose. This compose image installs and links all the necessary containers to get you started. The four containers are:

  1. compose_kong (KONG API Gateway)
  2. postgres:9.4 (Kong Database)
  3. compose_nginx-lb (NGINX-Load Balancer)
  4. progrium/consul (Console)

High Level Tasks

  • Install: Kong with Docker compose
  • Verify: Install
  • Check: Kong status

Install Kong with Docker Compose

####Run Docker Compose Locate the Kong Docker Compose files you downloaded in the pre-requisites.

Run this command in a command line.

Note: Make sure you specify the path of the Kong compose folder (e.g. /desktop/docker-kong-master/compose/)

$ <path_kong_compose_file>/docker-compose up

Verify Install

Send a request to Kong via the admin api port:8001

$ http localhost:8001

You should receive an HTTP 200 response similar to this:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Fri, 28 Sept 2017 14:42:10 GMT
Server: kong/0.11.0
Transfer-Encoding: chunked
{
  Configurations...
}

Congratulations! A response indicates that Kong was installed successfully. More specifically, a response indicates that the Kong admin api port is listening via 8001. You will use this port to configure Kong in subsequent exercises.


Access Shell

Now, lets access the Kong container shell to verify that all systems and dependencies are running properly.

$ docker exec -it docker compose_kong /bin/bash

Important Note: The Kong Docker container name above is compose_kong. If this doesn’t work use the Container ID

To obtain a list of container Id(s) run:

$ docker ps -a

Show Kong Commands

Now that you are in Kong shell, to view a list of Kong commands type:

# kong ?

The response provides list of Kong commands

Usage: kong COMMAND [OPTIONS]
The available commands are:
 check
 compile
 health
 migrations
 prepare
 quit
 reload
 restart
 roar
 start
 stop
 version

Options:
 --v              verbose
 --vv             debug

Check Kong Status

Lets check to make sure that SERF and NGINX dependencies are running using the kong health command

# kong health

The response looks like this

nginx.......running

Kong is healthy at /usr/local/kong

NOTE: Kong version 0.10.3 and below include a Serf dependency. In Kong version 0.11.0, Serf is no longer required.

Summary

CONGRATULATIONS - You have completed this lab and the following tasks:

  • Install: Kong with Docker compose
  • Verify: Install
  • Check: Kong status

What Next

You’ve just installed Kong and its dependencies using the Kong Docker Compose image. Let’s continue by creating your first.

Protect and Rate Limit Your API

Edit this page