kong的管理UI选择-konga


前言
当前KONG的社区版是没有dashboard的,但是付费的企业版是有带的。
GitHub上开源且还在更新维护的dashboard有两个

  • kong-dashboard:Kong Dashboard 3.3.0 is only partially compatible with Kong 0.13. It does not support the new Service and Route objects introduced in Kong 0.13.
  • konga:From 0.14.0 onwards, Konga is ONLY compatible with Kong >= 1.0.0

根据GitHub说明得知
kong-dashboard最新版本v3.6.0,只能支持到kongv0.14.x,对于kong的更高版本,功能支持不齐全;
konga从0.14.0开始,仅与Kong> = 1.0.0兼容。Konga 0.12+与Kong 0.14+完全兼容。较早的Kong版本仍然兼容,但不能保证。

虽然,市面上kong-dashboard应用比较广泛,但kong的功能不断强大,伴随着版本更替,个人觉得还是使用支持及更新高效的kongaUI比较好。


npm方式安装

依赖

  • 安装npm
  • node: version >= 8.x

lib库

  • Sails.js
  • AngularJS

1. 准备依赖环境

Install npm and node.js

wget -P /app/tools/ https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz
tar -xf /app/tools/node-v8.11.3-linux-x64.tar.xz -C /opt/
cd /opt/
mv node-v8.11.3-linux-x64 nodejs
echo 'export PATH=$PATH:/opt/nodejs/bin' >> /etc/profile
source /etc/profile

Install bower, ad gulp packages

# 如果下载慢,可以修改npm源:$ npm --registry https://registry.npm.taobao.org info underscore 
npm install -g gulp
npm install -g bower
npm install -g sails
npm install -g angular

验证一下版本

node -v
npm -v 

2. 安装konga

cd /opt/
git clone https://github.com/pantsel/konga.git
cd konga
#npm install konga
npm install --unsafe-perm=true --allow-root
npm i pm2 -g

3. 配置

项目内已经提供了配置文件用例.env_example,复制为.env并修改配置项即可。

关键的配置有PORT、DB_ADAPTER、DB_URI、DB_USER、DB_PASSWORD等。

cp .env_example .env

$ vim .env,根据自身环境修改,默认配置如下:

PORT=1337
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=postgres
#DB_HOST=127.0.0.1
#DB_PORT=5432
#DB_USER=konga
#DB_PASSWORD=konga
#DB_DATABASE=konga
DB_URI=postgresql://konga:konga@localhost:5432/konga
KONGA_LOG_LEVEL=warn
TOKEN_SECRET=some_secret_token

4. 环境变量(more)

  • https://github.com/pantsel/konga/tree/master

5. 数据库

配置

konga的数据库支持

  1. MySQL
  2. MongoDB
  3. PostgreSQL
    为了使用它们,请在.env文件中设置适当的环境变量。

我选用的是PostgreSQL,版本建议9.6,过高可能出现不兼容状况。为了保障一切顺利进行,pgsql的部署可参考[postgresql安装及配置]

[root@sltkp3cbpch konga]# su - postgres
Last login: Wed Nov 27 16:39:27 CST 2019 on pts/0
-bash-4.2$ psql
Password:
psql (10.11)
Type "help" for help.

postgres=# create user konga with password 'konga';
CREATE ROLE
postgres=# create database konga owner konga;
CREATE DATABASE
postgres=# grant all privileges on database konga to konga;
GRANT
postgres=#

重启生效

systemctl restart postgresql-10

初始化/迁移

如果连接的是MySQL或PostgresSQL,则在生产模式下运行时,Konga将不会执行数据库迁移。
您可以通过调用$ node ./bin/konga.js prepare 传递数据库连接所需的args 来手动执行迁移。

node ./bin/konga.js prepare --adapter postgres --uri postgresql://konga:[email protected]:5432/konga

6. 运行

启动
创建日志目录

mkdir -p /opt/konga/logs/

启动脚本$ sh /scripts/kong/konga.sh

# 官方启动方式
nohup npm run production &
# 其他启动方式(建议使用):
pm2 start app.js --name konga
pm2 start npm --name 'konga' -- run production

登录验证
用浏览器打开Konga地址,一般是http://localhost:1337,显示界面如下:
由于当前没有管理员,所以需要注册一个管理员。

注册后若没有跳转,显示为空白页面,则执行:

npm run bower-deps
npm install dotenv-extended
npm install unirest

完成登录后,由于没有连接到Kong,因此需要新建一个到Kong的链接

Docker方式安装

待整理,由于使用了npm方式,这里就不细写了;
npm简单方便,以下提供两个参考连接:

  • https://github.com/pantsel/konga/tree/master
  • https://segmentfault.com/a/1190000020375323

关于Kong-Dashboard

由于本人选用UI为konga,需要kong-dashboard的资源请访问【GitHub】kong-dashboard

 
[sleepy↓]



猜你喜欢

转载自www.cnblogs.com/sunhongleibibi/p/11959381.html