星期四, 11月 02, 2017

KONG with openSUSE 安裝小記

最近因為工作的關係, 要接觸 open API Gateway 相關軟體

目前是使用 KONG 這套軟體
官網 https://getkong.org/

OS: openSUSE Leap 42.2

安裝方式
使用 docker 安裝 參考

  • :8001 Admin API
  • :8000 http listen port, 要使用 :8000 去 call


架構上面的差異( 圖片取自官網 )

傳統方式
螢幕快照 2017-04-17 下午3.00.45.png

使用 KONG 方式

螢幕快照 2017-04-17 下午3.00.58.png


版本 kong:latest 測試
  • 目前 postgres DB 可以裝, 但是 cassandra DB 不能裝

# docker  run  -d  --name  kong-database  -p  5432:5432  -e "POSTGRES_USER=kong"   -e   "POSTGRES_DB=kong"   postgres:9.4

確認 container 狀態

# docker   ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
5a57787d07b5        postgres:9.4                 "/docker-entrypoint.s"   22 seconds ago      Up 20 seconds       0.0.0.0:5432->5432/tcp   kong-database
534536da7827        pgbi/kong-dashboard:v2.0.0   "/bin/sh -c 'npm run "   6 months ago        Up 2 weeks          0.0.0.0:8080->8080/tcp   tiny_cori

之前在 0.10.1 的時候沒有 migrations 這個步驟, 現在多了這個部份, 下次來研究
Run the migrations with an ephemeral Kong container


# docker   run  --rm   --link   kong-database:kong-database   -e "KONG_DATABASE=postgres"  -e   "KONG_PG_HOST=kong-database"   -e  "KONG_CASSANDRA_CONTACT_POINTS=kong-database"   kong:latest   kong  migrations   up


migrating core for database kong
core migrated up to: 2015-01-12-175310_skeleton
core migrated up to: 2015-01-12-175310_init_schema
core migrated up to: 2015-11-23-817313_nodes
core migrated up to: 2016-02-29-142793_ttls
migrating hmac-auth for database kong
hmac-auth migrated up to: 2015-09-16-132400_init_hmacauth
migrating rate-limiting for database kong
rate-limiting migrated up to: 2015-08-03-132400_init_ratelimiting
rate-limiting migrated up to: 2016-07-25-471385_ratelimiting_policies
migrating acl for database kong
acl migrated up to: 2015-08-25-841841_init_acl
migrating ip-restriction for database kong
ip-restriction migrated up to: 2016-05-24-remove-cache
migrating jwt for database kong
jwt migrated up to: 2015-06-09-jwt-auth
jwt migrated up to: 2016-03-07-jwt-alg
migrating galileo for database kong
galileo migrated up to: 2016-04-15_galileo-import-mashape-analytics
migrating key-auth for database kong
key-auth migrated up to: 2015-07-31-172400_init_keyauth
migrating oauth2 for database kong
oauth2 migrated up to: 2015-08-03-132400_init_oauth2
oauth2 migrated up to: 2016-07-15-oauth2_code_credential_id
oauth2 migrated up to: 2016-12-22-283949_serialize_redirect_uri
migrating response-ratelimiting for database kong
response-ratelimiting migrated up to: 2015-08-03-132400_init_response_ratelimiting
response-ratelimiting migrated up to: 2016-08-04-321512_response-rate-limiting_policies
migrating basic-auth for database kong
basic-auth migrated up to: 2015-08-03-132400_init_basicauth
3 migrations ran


執行 kong 容器

# docker   run   -d   --name  kong  --link  kong-database:kong-database  -e "KONG_DATABASE=postgres"  -e   "KONG_PG_HOST=kong-database"  -e  "KONG_CASSANDRA_CONTACT_POINTS=kong-database"  -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"  -p  8000:8000   -p  8443:8443  -p  8001:8001  -p  8444:8444    kong:latest

這個部份看到在 kong 0.10.1 版本的時候有 listen 7946 TCP 與 UDP, 但是 kong:latest 目前沒有, 另外有多了 8444 這個 port

觀察相關資訊

# docker   ps

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                          NAMES
e37821a1d09f        kong:latest                  "/docker-entrypoint.s"   13 seconds ago      Up 12 seconds       0.0.0.0:8000-8001->8000-8001/tcp, 7946/tcp, 0.0.0.0:8443-8444->8443-8444/tcp   kong
5a57787d07b5        postgres:9.4                 "/docker-entrypoint.s"   4 minutes ago       Up 4 minutes        0.0.0.0:5432->5432/tcp                                                         kong-database


確認 kong 是否執行




===================================================

因為開發環境的關係, 使用 0.10.3 版本

# docker  run  -d  --name  kong-database  -p  5432:5432  -e "POSTGRES_USER=kong"   -e   "POSTGRES_DB=kong"   postgres:9.4

      0.0.0.0:8080->8080/tcp   tiny_cori


Run the migrations with an ephemeral Kong container


# docker   run  --rm   --link   kong-database:kong-database   -e "KONG_DATABASE=postgres"  -e   "KONG_PG_HOST=kong-database"   -e  "KONG_CASSANDRA_CONTACT_POINTS=kong-database"   kong:latest   kong  migrations   up



# docker   run   -d   --name  kong  --link  kong-database:kong-database  -e "KONG_DATABASE=postgres"  -e   "KONG_PG_HOST=kong-database"  -e  "KONG_CASSANDRA_CONTACT_POINTS=kong-database"  -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"  -p  8000:8000   -p  8443:8443  -p  8001:8001  -p  8444:8444    kong:0.10.3


# docker  ps

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                          NAMES
5e2f7a400396        kong:0.10.3                  "/docker-entrypoint.s"   17 seconds ago      Up 16 seconds       0.0.0.0:8000-8001->8000-8001/tcp, 7946/tcp, 0.0.0.0:8443-8444->8443-8444/tcp   kong
a4ce8f8aa964        postgres:9.4                 "/docker-entrypoint.s"   2 minutes ago       Up 2 minutes        0.0.0.0:5432->5432/tcp                                                         kong-database
534536da7827        pgbi/kong-dashboard:v2.0.0   "/bin/sh -c 'npm run "   6 months ago        Up 2 weeks          0.0.0.0:8080->8080/tcp                                                         tiny_cori




沒有留言: