美文网首页
kong&konga本地部署

kong&konga本地部署

作者: Ballpenww | 来源:发表于2020-07-03 12:51 被阅读0次

    官方文档

    https://docs.konghq.com/install/docker/?_ga=2.267595406.1889843856.1593682121-1006865738.1585120351

    部署

    部署postgresql

    创建网络

    docker network create kong-net
    

    创建数据卷

    docker volume create pgsql docker volume create kong konga
    

    部署postgres:

    ➜ docker run -d --name kong-database \ 
    --network=kong-net \ 
    -p 54432:5432 \ 
    -e "POSTGRES_PASSWORD=pgsql" \ 
    -v /$your_path/pgsql/data:/var/lib/postgresql/data \ 
    -v /$your_path/pgsql/etc:/etc/postgresql \
     postgres:9.6 
    

    添加数据库信息

    docker exec -it kong-database bash 
    > su postgres 
    > psql -h localhost --password 
    # 输入密码
    # 通过一下语句创建账户和数据库
    CREATE USER kong password 'kong'; 
    CREATE DATABASE kong OWNER kong; 
    grant all privileges on database kong to kong;   
    
    CREATE USER konga password 'konga'; 
    CREATE DATABASE konga OWNER konga; 
    grant all privileges on database konga to konga;
    

    部署kong

    准备数据

    ➜ docker run --rm \ 
    --network=kong-net \ 
    -e "KONG_DATABASE=postgres" \ 
    -e "KONG_PG_HOST=kong-database" \ 
    -e "KONG_PG_USER=kong" \ 
    -e "KONG_PG_PASSWORD=kong" \ 
    -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ 
    kong:latest kong migrations bootstrap
    

    启动kong:

    ➜ docker run -d --name kong \ 
    --network=kong-net \ 
    -e "KONG_DATABASE=postgres" \ 
    -e "KONG_PG_HOST=kong-database" \ 
    -e "KONG_PG_USER=kong" \ 
    -e "KONG_PG_PASSWORD=kong" \ 
    -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" \ 
    -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
    

    部署konga:

    https://hub.docker.com/r/pantsel/konga

    准备数据库:

    docker run --network=kong-net --rm pantsel/konga -c prepare -a postgres -u postgresql://konga:konga@kong-database/konga
    

    启动konga:

    docker run -d -p 1337:1337 --name konga \ 
    --network=kong-net \ 
    -e "TOKEN_SECRET=${自己随机生成一个}" \ 
    -e "DB_ADAPTER=postgres" \ 
    -e "DB_HOST=kong-database" \ 
    -e "DB_PORT=5432" \ 
    -e "DB_USER=konga" \ 
    -e "DB_PASSWORD=konga" \ 
    -e "DB_DATABASE=konga" \ 
    -e "NODE_ENV=development" \ 
    pantsel/konga
    

    konga连接kong:

    因为konga和kong都在kong-net这个网络中,所以需要使用kong的kong-net IP, 通过inspect 获得kong地址

    ➜  docker docker inspect kong | grep -i ipaddress
                "SecondaryIPAddresses": null,
                "IPAddress": "",
                        "IPAddress": "172.18.0.3",
    
    image.png

    相关文章

      网友评论

          本文标题:kong&konga本地部署

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