DEV Community

Setup (Kong + Konga) as API Gateway

Kelvin on April 09, 2020

Welcome! You are about to start on a journey about and how to setup kong as an API Gateway for your infrastructure. In this second chapter, We are ...
Collapse
 
jamallmahmoudi profile image
JamallMahmoudi

Hi cool& perfect

Collapse
 
vousmeevoyez profile image
Kelvin

if this helps please support me so i can produce more quality content to help other developers
Buy Me A Coffee

Collapse
 
netanyahuisgay profile image
Info Comment hidden by post author - thread only accessible via permalink
TechDebtDevin

Do not give this guy money for this guide until he improves it. I'd happily give him money to delete this fucking thing tbh.

Collapse
 
ayyappa99 profile image
Ayyappa

@vousmeevoyez : Unfortunately, running the same exact script giving below error
'FATAL: database "konguser" does not exist'

Collapse
 
vousmeevoyez profile image
Kelvin

Hi could you share more details? do you run it using start.sh? or just docker-compose?

Collapse
 
ayyappa99 profile image
Ayyappa

I ran with start.sh script
Also what i noticed was the db name needs to be kong always else kong is throwing kong database doesn't exist.

Thread Thread
 
vousmeevoyez profile image
Kelvin

yes, I forgot to mention that in article. thanks man

Collapse
 
giesberge profile image
giesberge

I've tried from both and I have the same error,

Thread Thread
 
vousmeevoyez profile image
Kelvin

hi could you share your error?

Thread Thread
 
giesberge profile image
giesberge

database "konguser" does not exist. This is also after running a docker system prune:
pastebin.com/yJkp7BYK

Thread Thread
 
vousmeevoyez profile image
Kelvin

Hi giesberge can you try with this following sequence

  • docker system prune --volumes
  • mv .env.sample .env
  • update .env from
KONGA_ENV=production
Enter fullscreen mode Exit fullscreen mode

to

KONGA_ENV=development
Enter fullscreen mode Exit fullscreen mode
  • ./start.sh
  • go to localhost:9000

if this helps please support me so i can produce more quality content to help other developers
Buy Me A Coffee

Thread Thread
 
giesberge profile image
giesberge

Already done, I even tried changing the db_names but that didn't work. pastebin.com/wmcHb9Tw

Thread Thread
 
vousmeevoyez profile image
Kelvin

I've notice you're using windows. Did you use wsl? And what terminal are you running? Command prompt?

Collapse
 
tikam02 profile image
Tikam Singh Alma

I ran with start.sh script
db_1 | FATAL: database "konguser" does not exist

Collapse
 
vousmeevoyez profile image
Kelvin

Hi Tikam, sorry for slow response. Been very busy this couple months. try stop and clearing all volumes

docker-compose down
docker system prune --volumes
Enter fullscreen mode Exit fullscreen mode

also use this setting as .env

# KONG SETTING
KONG_DB_NAME=db_kong
KONG_DB_USERNAME=konguser
KONG_DB_PASSWORD=kongpassword
KONG_DB_HOST=db
KONG_DB_PORT=5432

KONG_DATABASE=postgres
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

KONG_PROXY_PORT=8000
KONG_PROXY_SSL_PORT=8443

# KONGA SETTING
KONGA_DB_NAME=db_konga
KONGA_DB_USERNAME=kongauser
KONGA_DB_PASSWORD=kongapassword
KONGA_DB_HOST=db
KONGA_DB_PORT=5432

KONGA_TOKEN_SECRET=some-secret-token
KONGA_ENV=production
KONGA_PORT=9000
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tikam02 profile image
Tikam Singh Alma

Thank you so much @kelvin for the help.

Collapse
 
tiagosmx profile image
Tiago Stapenhorst Martins

Brilliant post dude! Your guide is valuable and well written.
I have been trying with no success to setup Kong and Konga with docker a while ago by following their git and official pages. Their documentation aren't very friendly indeed.
Thanks!

Collapse
 
netanyahuisgay profile image
Info Comment hidden by post author - thread only accessible via permalink
TechDebtDevin

This is my third time writing this comment, the first two were too mean and somewhat stupid on my part. However, I do want to emphasize that this is not a great guide and you are far better off setting up Kong and Konga on your own via their docs. I really wish authors would delete these guides or improve them, its clear 90% of people hit very confusing errors following this process and wasted a ton of time in the process. Just read kong docs. Crazy this guy asks for people to give him money, please improve your guide or delete it @vousmeevoyez. Yes I'm getting the same error 50x that everyone else has described here, your recommended fixes are not fixes and only cause us to waste more time. Please please delete or fix. I really don't want to be mean or rude here but its hard to be nice when this guide caused me such a massive headache.

Collapse
 
hendisantika profile image
Hendi Santika

Can We add all the env vars from .env file to docker-compose.yml file?

Collapse
 
vousmeevoyez profile image
Kelvin

yes you can

Collapse
 
hendisantika profile image
Hendi Santika

But, I tried it and it was failed. ENV not detected

Thread Thread
 
vousmeevoyez profile image
Kelvin

can you tried edit

    kong-migrations:
      image: kong:latest
      entrypoint: sh -c "sleep 10 && kong migrations bootstrap -v"
      environment:
        KONG_DATABASE: ${KONG_DATABASE}
        KONG_PG_HOST: ${KONG_DB_HOST}
        KONG_PG_DATABASE: ${KONG_DB_NAME}
        KONG_PG_USER: ${KONG_DB_USERNAME}
        KONG_PG_PASSWORD: ${KONG_DB_PASSWORD}
Enter fullscreen mode Exit fullscreen mode

to

    kong-migrations:
      image: kong:latest
      entrypoint: sh -c "sleep 10 && kong migrations bootstrap -v"
      env_file:
        - .env
      depends_on:
      - db
      networks:
      - kong-net
      restart: on-failure

    kong:
      image: kong:latest
      restart: on-failure
      env_file:
        - .env
      ports:
      - $KONG_PROXY_PORT:8000
      - $KONG_PROXY_SSL_PORT:8443
        #- $KONG_PROXY_ADMIN_API_PORT:8001
        #- $KONG_PROXY_ADMIN_SSL_API_PORT:8444
      networks:
      - kong-net

    konga:
      image: pantsel/konga
      env_file:
        - .env
      restart: on-failure
      ports:
      - $KONGA_PORT:1337
      depends_on:
      - db
      networks:
      - kong-net

Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
hendisantika profile image
Hendi Santika

localhost:9000/ doesn't show anything

Thread Thread
 
vousmeevoyez profile image
Kelvin

I'm helping software engineer around the world solving the hard problem so they can focus on the actual problem.

Please support me through link below so i can help other developers
buymeacoffee.com/kelvindsmn/

Collapse
 
fruitninja156 profile image
firew

Hey, I keep getting this error..

Image description

Collapse
 
vousmeevoyez profile image
Kelvin

Hi can you run the repo by executing the shell script?

./start.sh
Enter fullscreen mode Exit fullscreen mode
Collapse
 
fruitninja156 profile image
firew

Hey, sorry for the late response got that error while executing with ./start.sh

Collapse
 
amirhs712 profile image
amirhs712

where do I get docker-entrypoint.sh?

Collapse
 
vousmeevoyez profile image
Kelvin

Hi amirhs, terribly sorry for slow response. You can find the docker-entrypoint for the postgres container here github.com/vousmeevoyez/kong-konga...

Some comments have been hidden by the post's author - find out more