Public | Automated Build

Last pushed: a year ago
Short Description
Extension of official docker kong image with added support for Rancher, Kubernetes or Docker Cloud
Full Description

Kong as a Docker Service

This an extension of the official Docker image for Kong, with support to for Rancher, Kubernetes, or Tutum/Docker Cloud.

You can also spin this up by adding in my custom Rancher Catalog

Justifications

The official docker-kong image allows for:

1. linking `Cassandra` or `Postgres` database containers
2. connecting to external databases via custom `kong.yml` config file by replacing the `/etc/kong/` volume.

However when using Rancher or Kubernetes, containers are organised into Services deployed across multiple machine node clusters. Therefore it's not feasible to mount custom config files into volumes on each machine which are spun up and down on demand. See related question here

Also there is no need to explicitly link containers since internal DNS resolutions for Services comes out of the box in platforms such as Rancher or Tutum.

By configuring Cassandra and Postgres purely using Environment Variables, it is a lot easier to point to either an external database instance or an internal database service. Without having to build a custom kong config.

Supported tags and respective Dockerfile links

How to use this image

Existing docker-kong usages still applies. The following extra Environment Variables are added:

Kong Environment Variables:

Env Var Default Description
DATABASE cassandra either cassandra or postgres as per official image
CLUSTER_LISTEN 0.0.0.0:7946 host ip and port. When rancher is specified, uses the Rancher Meta Data Service to work out the correct container ip address for cluster_listen. Other platforms can be extended quite easily.

Cassandra Environment Variables:

Env Var Default Description
CASSANDRA_CONTACT_POINTS kong-database:9046 Mandatory. Specify custom values in the format of \"ip1:9046\",\"ip2:9046\" or use a internal service name
CASSANDRA_KEYSPACE kong Optional
CASSANDRA_USER kong Optional
CASSANDRA_PASSWORD kong Optional

Example:

$ docker run -d --name kong \
    -e DATABASE=cassandra \
    -e CASSANDRA_CONTACT_POINTS='\"52.5.149.55:9042\",\"52.5.149.56:9042\"' \
    -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 7946:7946 -p 7946:7946/udp \
    littlebaydigital/kong

or:

$ docker run -d --name kong \
    -e DATABASE=cassandra \
    -e CASSANDRA_CONTACT_POINTS='\"cassandra-service.kong-stack:9042\"' \
    -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 7946:7946 -p 7946:7946/udp \
    littlebaydigital/kong

Sample Docker Compose: https://github.com/yunspace/my-docker-stacks/tree/master/kong/cassandra

Postgres Environment Variables:

Env Var Default Description
POSTGRES_HOST kong-database Mandatory. Either a external hostname or internal service name
POSTGRES_PORT 5432 Optional.
POSTGRES_DATABASE kong Optional.
POSTGRES_USER kong Optional.
POSTGRES_PASSWORD kong Optional.

Example:

$ docker run -d --name kong \
    -e DATABASE=postgres \
    -e POSTGRES_HOST=127.0.0.1 \
    -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 7946:7946 -p 7946:7946/udp \
    --security-opt seccomp:unconfined \
    littlebaydigital/kong

or:

$ docker run -d --name kong \
    -e DATABASE=postgres \
    -e POSTGRES_HOST=postgres-service.kong-stack \
    -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 7946:7946 -p 7946:7946/udp \
    --security-opt seccomp:unconfined \
    littlebaydigital/kong

Sample Docker Compose: https://github.com/yunspace/my-docker-stacks/tree/master/kong/postgres

Docker Pull Command
Owner
littlebaydigital

Comments (2)
hanselke
4 months ago

tried upgrading it to 0.10.2 and im getting
6 22:37:172017/05/16 14:37:17 [debug] upstream_keepalive = 60
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] prefix in use: /usr/local/kong
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] preparing nginx prefix directory at /usr/local/kong
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] saving serf identifier to /usr/local/kong/serf/serf.id
2017-5-16 22:37:172017/05/16 14:37:17 [debug] searching for OpenResty 'resty' executable
2017-5-16 22:37:172017/05/16 14:37:17 [debug] /usr/local/openresty/bin/resty -V: 'nginx version: openresty/1.11.2.2'
2017-5-16 22:37:172017/05/16 14:37:17 [debug] found OpenResty 'resty' executable at /usr/local/openresty/bin/resty
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] saving serf shell script handler to /usr/local/kong/serf/serf_event.sh
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] SSL enabled, no custom certificate set: using default certificate
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] default SSL certificate found at /usr/local/kong/ssl/kong-default.crt
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] Admin SSL enabled, no custom certificate set: using default certificate
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] admin SSL certificate found at /usr/local/kong/ssl/admin-kong-default.crt
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] running datastore migrations
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] could not start Kong, stopping services
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] leaving serf cluster
2017-5-16 22:37:172017/05/16 14:37:17 [verbose] stopped services
2017-5-16 22:37:17Error:
2017-5-16 22:37:17/usr/local/share/lua/5.1/kong/cmd/start.lua:34: /usr/local/share/lua/5.1/kong/cmd/start.lua:21: [postgres error] could not get current migrations: [postgres error] connection refused
2017-5-16 22:37:17stack traceback:
2017-5-16 22:37:17 [C]: in function 'error'
2017-5-16 22:37:17 /usr/local/share/lua/5.1/kong/cmd/start.lua:34: in function 'cmd_exec'
2017-5-16 22:37:17 /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
2017-5-16 22:37:17 [C]: in function 'xpcall'
2017-5-16 22:37:17 /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
2017-5-16 22:37:17 /usr/local/bin/kong:5: in function 'file_gen'
2017-5-16 22:37:17 init_worker_by_lua:38: in function <init_worker_by_lua:36>
2017-5-16 22:37:17 [C]: in function 'pcall'
2017-5-16 22:37:17 init_worker_by_lua:45: in function <init_worker_by_lua:43>

any idea whats wrong?

throrin19
7 months ago

Hi, with the version 0.8.3-1 I have this error on running :

sed: -e expression #1, char 25: unknown option to `s'