Administrator
发布于 2022-11-24 / 12 阅读
0
0

1、Get Kong

Kong官方docker仓库地址

  • 在部署Kong之前,先部署一个数据库;

docker run -d --name kong-database \
                -p 5432:5432 \
                -e "POSTGRES_USER=kong" \
                -e "POSTGRES_DB=kong" \
                -e "POSTGRES_PASSWORD=kong" \
                postgres:9.6
  • 以及录入一些数据

docker run --rm \
    --link kong-database:kong-database \
    -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 kong migrations bootstrap
  • 现在部署Kong

docker run -d --name kong \
    --link kong-database:kong-database \
    -e "KONG_DATABASE=postgres" \
    -e "KONG_PG_HOST=kong-database" \
    -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
    
  • Kong_Docker-Compose.yaml文件

version: "3"
services:
  kong:
    image: kong:2.7.0
    container_name: kong
    ports:
      - "80:8000"
      - "443:8443"
      - "7000:7000"
      - "8001:8001"
      - "8444:8444"
    networks:
      swarm-overlay: {}
   # volumes:
   #   - ./logs:/home/kong/logs
    environment:
      - KONG_DATABASE=postgres
      - KONG_PG_HOST=postgres
      - KONG_PG_USER=kong
      - KONG_PG_PASSWORD=kong
      - KONG_PG_DATABASE=kong
    #  - KONG_PROXY_ACCESS_LOG=/home/kong/logs/access.log
    #  - KONG_ADMIN_ACCESS_LOG=/home/kong/logs/admin_access.log
    #  - KONG_PROXY_ERROR_LOG=/home/kong/logs/error.log
    #  - KONG_ADMIN_ERROR_LOG=/home/kong/logs/admin_error.log
      - KONG_PROXY_LISTEN=0.0.0.0:8000, 0.0.0.0:8443 ssl http2
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_DNS_STALE_TTL=0
      - KONG_DNS_VALID_TTL=0
      - KONG_LUA_SSL_TRUSTED_CERTIFICATE=system
      - KONG_STREAM_LISTEN=0.0.0.0:7000
    restart: on-failure
    cpu_count: 1
    mem_limit: 512m
    #command: kong migrations bootstrap
    #command: kong start --v

networks:
  swarm-overlay:
    external: true


评论