kong Gateway && PostgreSQL 的安装(docker)

第一步:安装 PostgreSQL :

 sudo docker pull  postgres:9.6

1.1:创建network

sudo docker network create kong-net

1.2:运行镜像

sudo docker run -itd  --restart unless-stopped --name kong-database --network=kong-net  -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_PASSWORD=root" -e "POSTGRES_DB=kong"  postgres:9.6

第二步:安装 kong gateway :

2.1  下载 镜像

sudo docker pull kong:1.1.2

2.2 运行镜像

sudo docker run -d  --restart unless-stopped --name kong      --network=kong-net      -e "KONG_DATABASE=postgres"    -e "KONG_PG_HOST=kong-database"  -e "KONG_PG_PASSWORD=ACahlofh" -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:1.1.2

说明:

sudo docker run -d  --restart unless-stopped --name kong     

 --network=kong-net     

 -e "KONG_DATABASE=postgres"       //使用的数据库类型

-e "KONG_PG_HOST=kong-database"  

-e "KONG_PG_PASSWORD=ACahlofh"

-e "KONG_PROXY_ACCESS_LOG=/dev/stdout"    //log l路径

-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:1.1.2

proxy_listen_ssl:如果启用ssl,此配置就是KONG用来接收HTTP请求的地址和端口。默认值为 0.0.0.0:8443。

    admin_listen:Kong针对管理员提供的入口地址和端口。该API允许您配置和管理Kong,应该配置为持私的,并确保其是安全的。默认值为 0.0.0.0:8001

    admin_listen_ssl:在启用ssl的情况下的管理员对kong进行管理的入口。默认值为 0.0.0.0:8444

    nginx_worker_processes:配置Nginx服务开启后,可以产生的工作进程数。详情参考 http://nginx.org/en/docs/ngx_core_module.html#worker_processes。默认为 auto。

    nginx_daemon:配置Nginx是作为守护进程还是作为前台进程运行。主要用于开发或在Docker环境中运行Kong时。详见 http://nginx.org/en/docs/ngx_core_module.html#daemon。默认为on。

 

-e 环境变量 具体可以参考:https://www.cnblogs.com/SummerinShire/p/6624548.html

 Kong将其所有数据(如API,用户和插件)存储在Cassandra或PostgreSQL中。 属于同一集群的所有Kong节点必须连接到同一个数据库。

    database:配置此节点来指定KONG使用哪个数据库(PostgreSQL或Cassandra)作为其数据存储。可选的数据库只有postgres和cassandra。默认为 postgres。

      Postgres的设置:

        pg_host:Postgres的服务器的主机地址

        pg_port:Postgres的服务器的端口

        pg_user:Postgres用户名

        pg_password:Postgres的用户密码

        pg_database:要连接的数据库实例名,必须存在

        pg_ssl:是否启用与服务器的SSL连接

        pg_ssl_verify:如果启用了pg_ssl,则切换服务器证书验证。请参阅lua_ssl_trusted_certificate设置。

      Cassandra的设置:

        cassandra_contact_points:集群名称列表,以逗号分隔

        cassandra_port:您的节点正在监听的端口

        cassandra_keyspace:您在群集中使用的密钥空间,如果不存在将被自动创建

        cassandra_consistency:设置读写操作的一致性

        cassandra_timeout:读写操作的超时设定,单位为毫秒ms

        cassandra_ssl:配置启用SSL连接

        cassandra_ssl_verify:如果启用cassandra_ssl,则切换服务器证书验证。请参阅lua_ssl_trusted_certificate设置

        cassandra_username:使用PasswordAuthenticator方案时的用户名

        cassandra_password:使用PasswordAuthenticator方案时的用户密码

        cassandra_consistency:读/写Cassandra群集时使用的一致性设置

        cassandra_lb_policy:在Cassandra群集中分发查询时使用的负载均衡策略。接受的值是RoundRobin和DCAwareRoundRobin。当且仅当您使用多数据中心集群时方可配置,此时,请同时配置cassandra_local_datacenter选项

        cassandra_local_datacenter:当使用DCAwareRoundRobin策略时,必须在KONG节点中指定本地集群的名称

        cassandra_repl_strategy:如果是首次创建密钥空间,请指定复制策略

        cassandra_repl_factor:指定SimpleStrategy的复制条件

        cassandra_data_centers:指定NetworkTopologyStrategy的数据中心
View Code

 

猜你喜欢

转载自www.cnblogs.com/lshan/p/10909031.html