环境信息:
OS: CentOS 7 x86_64
防火墙: 关闭 systemctl stop firewalld
一、安装
1. Kong
当前Kong Dashboard兼容的Kong版本是0.12.x 不能通过 yum install 默认的方式去安装 kong,这样会默认安装最新版本的 kong,导致兼容问题。
1) 配置Kong repo信息
cat /etc/yum.repos.d/kong.repo [kong] name=Kong Community Edition baseurl=https://kong.bintray.com/kong-community-edition-rpm/centos/7 failovermethod=priority enabled=1 gpgcheck=0 repo_gpgcheck=0 yum install -y kong-community-edition-0.12.3-1.noarch
2) 安装 PostgreSQL 10
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm yum install postgresql10 yum install postgresql10-server /usr/pgsql-10/bin/postgresql-10-setup initdb systemctl enable postgresql-10 systemctl start postgresql-10
3) 配置PostgreSQL数据库,并创建Kong相关的数据库信息。
/var/lib/pgsql/10/data/postgresql.conf listen_addresses = '*' /var/lib/pgsql/10/data/pg_hba.conf host all all 127.0.0.1/32 trust systemctl restart postgresql-10 su - postgres -bash-4.1$ psql postgres=# CREATE USER kong; CREATE DATABASE kong OWNER kong; CREATE ROLE CREATE DATABASE postgres=# quit postgres-# \q -bash-4.1$ exit
4) 启动 Kong
kong migrations up kong start
5) 测试
curl -i http://localhost:8001/
输出如下信息并没有错误生成。
HTTP/1.1 200 OK Date: Tue, 08 May 2018 05:56:11 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Access-Control-Allow-Origin: * Server: kong/0.12.3 {"plugins":{"...
参考文档:
https://getkong.org/install/centos/?_ga=2.22984958.475071696.1525657125-1876323536.1524451300
2. Kong Dashboard
Kong-Dashboard 兼容版本信息
1) 安装 npm & Nodejs
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash - yum install -y nodejs
2) 安装Kong Dashboard
npm install -g kong-dashboard
3) 启动 Kong Dashboard
kong-dashboard start --kong-url http://<kong server>:8001
4) 测试
默认端口8080
浏览器中直接访问 http://<kong dashboard ip>:8080/ 显示如下图。
参考文档:
https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora
https://github.com/PGBI/kong-dashboard
二、添加API
1. 编写 RESTful API 程序
import web import yaml from tendo import colorer, singleton urls = ( '/manager/(.*)', 'manage', '/flavor/(.*)', 'flavor', ) app = web.application(urls, globals()) class flavor: def GET(self, name): if 'list' == name: return "[GET] Flavor list api" else: return "[GET] Flavor other api" class manage: def GET(self, name): return "[GET] VM Manage api" def POST(self, name): return "[POST] VM Manage api" def PUT(self, name): return "[PUT] VM Manage api" def DELETE(self, name): return "[DELETE] VM Manage api" if __name__ == "__main__": me = singleton.SingleInstance() app.run()
2. 测试程序可以正常访问
将上述代码保存在 demo.py 中,运行
python demo.py 1234
运行:
curl -X GET http://192.168.44.147:1234/manager/1
返回:
[GET] VM Manage api
3. 通过Kong Dashboard 界面添加该 API
配置如图所示,192.168.44.147是demo web的 ip 地址。
添加成功后,在界面显示如下
4. 测试
运行:
curl -X POST http://<kong ip address>:8000/manager/manager/1
返回:
[POST] VM Manage api
相关推荐
另一种是通过RESTful API,这是一个内部API,可用于管理Kong Gateway的配置和状态。RESTful API命令可以在集群中的任何节点上运行,确保了配置的一致性。 Kong还支持基于插件的模块化系统,允许开发者通过安装和...
1. **Kong Gateway**: 主要处理API请求和响应,执行各种操作如认证、限速、缓存等。 2. **Kong DB**: 用于存储API配置、消费者、插件配置等数据,可以使用内置的Cassandra或PostgreSQL数据库。 3. **Kong Admin API*...
Kong 正是这样一个 API Gateway,提供了许多有用的功能,例如优化的端点、请求折叠、身份验证、速率限制等。 在微服务架构中,API Gateway 发挥着至关重要的作用。它可以帮助简化客户端的复杂度,提供统一的 API ...
2. **API Gateway**:作为外部请求的入口,API Gateway负责路由、安全、限流等任务,减轻了后端服务的压力。可能集成Zuul或Kong等开源解决方案。 3. **配置管理**:配置中心如Spring Cloud Config或HashiCorp ...
scratch少儿编程逻辑思维游戏源码-减压游戏.zip
少儿编程scratch项目源代码文件案例素材-英勇之鸟.zip
少儿编程scratch项目源代码文件案例素材-羊羊繁殖V2.5.zip
scratch少儿编程逻辑思维游戏源码-加特林混战 多人游戏.zip
少儿编程scratch项目源代码文件案例素材-西装英雄.zip
在使用 R 语言进行科研绘图时,颜色的选择是一件让人特别纠结的事情。本系列文章介绍了 R 语言科研绘图时常用的一些配色。本资源给大家提供了文章对应的 PPT。
scratch少儿编程逻辑思维游戏源码-海洋战争.zip
少儿编程scratch项目源代码文件案例素材-万圣夜惊魂.zip
HarmonyOS安全开发赋能,含有HarmonyOS多个场景的安全策略赋能
平台的服务端和客户端源码 整理出来的的游戏源码
scratch少儿编程逻辑思维游戏源码-街头霸王.zip
少儿编程scratch项目源代码文件案例素材-小船.zip
scratch少儿编程逻辑思维游戏源码-几何冲刺(4).zip
少儿编程scratch项目源代码文件案例素材-消灭病毒大作战.zip
scratch少儿编程逻辑思维游戏源码-功夫猫.zip
scratch少儿编程逻辑思维游戏源码-节奏积木 马里奥.zip