美文网首页
kong docker

kong docker

作者: 匿名用户xx | 来源:发表于2019-12-03 23:07 被阅读0次

    一、创建docker网络

    docker network create kong-net
    

    二、启动数据库

    docker run -d --name kong-database --network=kong-net -p 5432:5432 -e "POSTGREAS_USER=kong" -e "POSTGRE_DB=kong" postgres:9.6
    
    创建pgsql用户和库
    docker exec -it kong-database bash
    root@9ada594493a9:/# su - postgres
    postgres@9ada594493a9:~$ psql
    postgres=# create user kong;create database kong owner kong;
    

    三、准备数据库(初始化数据库)

    docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_POSTGRES_CONTACT_POINTS=kong-database" kong:latest kong migrations bootstrap
    

    [root@hostname ~]# docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_POSTGRES_CONTACT_POINTS=kong-database" kong:latest kong migrations bootstrap
    Bootstrapping database...
    migrating core on database 'kong'...
    core migrated up to: 000_base (executed)
    core migrated up to: 001_14_to_15 (executed)
    core migrated up to: 002_15_to_1 (executed)
    core migrated up to: 003_100_to_110 (executed)
    core migrated up to: 004_110_to_120 (executed)
    core migrated up to: 005_120_to_130 (executed)
    core migrated up to: 006_130_to_140 (executed)
    migrating hmac-auth on database 'kong'...
    hmac-auth migrated up to: 000_base_hmac_auth (executed)
    hmac-auth migrated up to: 001_14_to_15 (executed)
    hmac-auth migrated up to: 002_130_to_140 (executed)
    migrating oauth2 on database 'kong'...
    oauth2 migrated up to: 000_base_oauth2 (executed)
    oauth2 migrated up to: 001_14_to_15 (executed)
    oauth2 migrated up to: 002_15_to_10 (executed)
    oauth2 migrated up to: 003_130_to_140 (executed)
    migrating jwt on database 'kong'...
    jwt migrated up to: 000_base_jwt (executed)
    jwt migrated up to: 001_14_to_15 (executed)
    jwt migrated up to: 002_130_to_140 (executed)
    migrating basic-auth on database 'kong'...
    basic-auth migrated up to: 000_base_basic_auth (executed)
    basic-auth migrated up to: 001_14_to_15 (executed)
    basic-auth migrated up to: 002_130_to_140 (executed)
    migrating key-auth on database 'kong'...
    key-auth migrated up to: 000_base_key_auth (executed)
    key-auth migrated up to: 001_14_to_15 (executed)
    key-auth migrated up to: 002_130_to_140 (executed)
    migrating rate-limiting on database 'kong'...
    rate-limiting migrated up to: 000_base_rate_limiting (executed)
    rate-limiting migrated up to: 001_14_to_15 (executed)
    rate-limiting migrated up to: 002_15_to_10 (executed)
    rate-limiting migrated up to: 003_10_to_112 (executed)
    migrating acl on database 'kong'...
    acl migrated up to: 000_base_acl (executed)
    acl migrated up to: 001_14_to_15 (executed)
    acl migrated up to: 002_130_to_140 (executed)
    migrating response-ratelimiting on database 'kong'...
    response-ratelimiting migrated up to: 000_base_response_rate_limiting (executed)
    response-ratelimiting migrated up to: 001_14_to_15 (executed)
    response-ratelimiting migrated up to: 002_15_to_10 (executed)
    migrating session on database 'kong'...
    session migrated up to: 000_base_session (executed)
    34 migrations processed
    34 executed
    Database is up-to-date

    四、启动kong

    docker run -d --name kong \
         --network=kong-net \
         -e "KONG_DATABASE=postgres" \
         -e "KONG_PG_HOST=kong-database" \
         -e "KONG_POSTGRES_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" \
         -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
         -p 8000:8000 \
         -p 8443:8443 \
         -p 8001:8001 \
         -p 8444:8444 \
         kong:latest
    

    五、使用kong
    curl -i http://localhost:8001/

    六、安装kong-dashboard
    docker run --rm -p 8088:8080 pgbi/kong-dashboard start --kong-url http://内网ip:8001

    相关文章

      网友评论

          本文标题:kong docker

          本文链接:https://www.haomeiwen.com/subject/tuufgctx.html