Skip to content

Instantly share code, notes, and snippets.

@dmagda
Last active January 8, 2024 22:08
Show Gist options
  • Save dmagda/3661fe4f1dad898a539036dc3e0853ec to your computer and use it in GitHub Desktop.
Save dmagda/3661fe4f1dad898a539036dc3e0853ec to your computer and use it in GitHub Desktop.
Starting Kong on YugabyteDB

Create a custom Docker network:

docker network create custom-network

Start YugabyteDB:

rm -r ~/yb_docker_data
mkdir ~/yb_docker_data

docker run -d --name yugabytedb-node1 --net custom-network \
  -p 15433:15433 -p 7001:7000 -p 9001:9000 -p 5433:5433 \
  -v ~/yb_docker_data/node1:/home/yugabyte/yb_data --restart unless-stopped \
  yugabytedb/yugabyte:latest \
  bin/yugabyted start \
  --base_dir=/home/yugabyte/yb_data --daemon=false

Create the Kong database:

docker exec -it yugabytedb-node1 /home/yugabyte/bin/ysqlsh -h yugabytedb-node1 -p 5433 -c 'create database kong'

Perform Kong bootstrapping and migrations:

docker run --rm --network=custom-network \
  -e "KONG_PG_HOST=yugabytedb-node1" \
  -e "KONG_PG_PORT=5433" \
  -e "KONG_DATABASE=postgres" \
  -e "KONG_PG_PASSWORD=yugabyte" \
  -e "KONG_PG_USER=yugabyte" \
  kong:latest kong migrations bootstrap

Start Kong with Docker compose:

version: '3.9'
services:
  kong:
    image: kong:latest
    container_name: kong
    environment:
        LC_CTYPE: en_US.UTF-8
        LC_ALL: en_US.UTF-8
        KONG_DATABASE: "postgres"
        KONG_PG_HOST:  "yugabytedb-node1"
        KONG_PG_PORT: "5433"
        KONG_PG_USER: "yugabyte"
        KONG_PG_PASSWORD: "yugabyte"        
        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     
    restart: on-failure
    ports:
      - '80:8000'
      - '443:8443'
      - '8001:8001'
      - '8444:8444'
  konga:
    image: pantsel/konga
    ports:
      - '1337:1337'
    links:
      - 'kong:kong'
    container_name: konga
    environment:
      - NODE_ENV=production

networks:
  default:
    name: custom-network

Check the logs:

docker logs kong -f

The logs should be as follows:

docker logs kong -f
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = "en_US.UTF-8",
	LC_CTYPE = "en_US.UTF-8",
	LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = "en_US.UTF-8",
	LC_CTYPE = "en_US.UTF-8",
	LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
2024/01/08 22:05:04 [warn] 1#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:7
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:7
2024/01/08 22:05:04 [notice] 1#0: [lua] init.lua:775: init(): [request-debug] token for request debugging: 2a267df6-7bc2-45df-a214-84463dfc3811
2024/01/08 22:05:04 [notice] 1#0: using the "epoll" event method
2024/01/08 22:05:04 [notice] 1#0: openresty/1.21.4.2
2024/01/08 22:05:04 [notice] 1#0: OS: Linux 5.10.76-linuxkit
2024/01/08 22:05:04 [notice] 1#0: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/01/08 22:05:04 [notice] 1#0: start worker processes
2024/01/08 22:05:04 [notice] 1#0: start worker process 1279
2024/01/08 22:05:04 [notice] 1#0: start worker process 1280
2024/01/08 22:05:04 [notice] 1#0: start worker process 1281
2024/01/08 22:05:04 [notice] 1#0: start worker process 1282
2024/01/08 22:05:04 [notice] 1#0: start worker process 1283
2024/01/08 22:05:04 [notice] 1#0: start worker process 1284
2024/01/08 22:05:04 [notice] 1#0: start worker process 1285
2024/01/08 22:05:04 [notice] 1#0: start worker process 1286
2024/01/08 22:05:08 [notice] 1279#0: *1 [lua] warmup.lua:110: single_dao(): Preloading 'services' into the core_cache..., context: init_worker_by_lua*
2024/01/08 22:05:08 [notice] 1279#0: *1 [lua] warmup.lua:159: single_dao(): finished preloading 'services' into the core_cache (in 0ms), context: init_worker_by_lua*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment