Virtual Machine
우분투 18.04.2
도커 환경
docker를 이용하기 때문에 DB, Kong 컨테이너 간 통신을 위해서 docker network를 생성하여 네트워크를 구성
docker network create kong-net
PostgreSQL로 설치
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
-e "POSTGRES_PASSWORD=kongpass" \
postgres:9.6
2번에서 Database를 PostgreSQL로 설치는 완료했지만, 저 DB는 현재 아무것도 없는 껍데기 상태의 DB이기 때문에, kong의 bootstrap환경을 migration하여 DB 스키마를 최초 설정
docker run --rm --network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kongpass" \
-e "KONG_PASSWORD=test" \
kong/kong-gateway:3.1.1.2 kong migrations bootstrap
docker run -d --name kong-gateway \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kongpass" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
-e "KONG_ADMIN_GUI_URL=http://localhost:8002" \
-e KONG_LICENSE_DATA \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
-p 8002:8002 \
-p 8445:8445 \
-p 8003:8003 \
-p 8004:8004 \
kong/kong-gateway:3.1.1.2
curl이 설치되어 있지 않으면
apt install curl
localhost:8001번의 /services 엔드포인트로 GET요청하여 확인
curl -i -X GET --url http://localhost:8001/services
브라우저를 열어서도 확인 가능
http://localhost:8002