Kong Gateway 是一个轻量级、快速、灵活的云原生 API 网关。API 网关是一种反向代理,可让您管理、配置和将请求路由到您的 API。

官网
Kong官方文档:Kong Docs

Kong下载地址:Installations - KongHQ

RPM包下载: https://docs.konghq.com/install/centos/

参考文档:php实战kong做微服务架构一(kong简介与安装)_小猴子喝牛奶的博客-CSDN博客_kong php

部署Kong
通过Docker部署

(1)创建网桥

docker network create kong-net
(2)安装postgres(你可以使用源码包安装,这里用docker安装)

docker run -d --name kong-database \--network=kong-net \-p 5432:5432 \-e "POSTGRES_USER=kong" \-e "POSTGRES_PASSWORD=Knight8888" \-e "POSTGRES_DB=kong" \-v kong_data:/var/lib/postgresql/data \postgres:9.6

(3) 查看版本

# 查看版本
kong version 
(4) 编辑配置文件

cp /etc/kong/kong.conf.default /etc/kong/kong.conf
vim /etc/kong/kong.conf,用于配置数据库的地址-- 省略
database = postgres             # Determines which of PostgreSQL or Cassandra# this node will use as its datastore.# Accepted values are `postgres`,# `cassandra`, and `off`.pg_host = 172.19.193.161             # Host of the Postgres server.
pg_port = 5432                  # Port of the Postgres server.
#pg_timeout = 5000               # Defines the timeout (in ms), for connecting,# reading and writing.pg_user = kong                  # Postgres user.
pg_password =  kong@8888                 # Postgres user's password.
pg_database = kong              # The database name to connect to.#pg_schema =                     # The database schema to use. If unspecified,# Kong will respect the `search_path` value of# your PostgreSQL instance.pg_ssl = off                    # Toggles client-server TLS connections# between Kong and PostgreSQL.# Because PostgreSQL uses the same port for TLS# and non-TLS, this is only a hint. If the# server does not support TLS, the established# connection will be a plain one.pg_ssl_verify = off             # Toggles server certificate verification if# `pg_ssl` is enabled.# See the `lua_ssl_trusted_certificate`# setting to specify a certificate authority.

-- 省略
通过yum安装部署PostGreSQL

(1)安装软件

$ yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
$ yum install -y postgresql96-server
$ systemctl enable postgresql-9.6

(2)修改环境变量

$ vim /etc/profile
$ export /usr/pgsql-9.6/bin:$PATH
$ source /etc/profile

(3)初始化数据

$ su - postgres
$ initdb -D /home/data/postgres/pgsql/data
$ psql

#创建kong数据库

$ CREATE USER kong; CREATE DATABASE kong OWNER kong;
$ ALTER USER  kong PASSWORD 'qq@123';  

#创建konga数据库

$ CREATE USER konga; CREATE DATABASE konga OWNER konga;
$ ALTER USER  konga PASSWORD 'qq@123';

(4) 修改数据目录

$ sed -i "s#/var/lib/pgsql/9.6/data/#/home/data/postgres/pgsql/data/#g" /usr/lib/systemd/system/postgresql-9.6.service
$ systemctl reload postgresql-9.6

修改配置文件:

$cat /etc/kong/kong.conf |grep "^pg_"
pg_host = 172.19.193.161             # Host of the Postgres server.
pg_port = 5432                  # Port of the Postgres server.
pg_user = kong                  # Postgres user.
pg_password = Knight8888                  # Postgres user's password.
pg_database = kong              # The database name to connect to.
pg_ssl = off                    # Toggles client-server TLS connections
pg_ssl_verify = off             # Toggles server certificate verification if

初始化数据

$sudo kong migrations bootstrap
Bootstrapping database...
migrating core on database 'kong'...
core migrated up to: 000_base (executed)
core migrated up to: 003_100_to_110 (executed)
core migrated up to: 004_110_to_120 (executed)
core migrated up to: 005_120_to_130 (executed)
core migrated up to: 006_130_to_140 (executed)
core migrated up to: 007_140_to_150 (executed)
core migrated up to: 008_150_to_200 (executed)
core migrated up to: 009_200_to_210 (executed)
core migrated up to: 010_210_to_211 (executed)
core migrated up to: 011_212_to_213 (executed)
core migrated up to: 012_213_to_220 (executed)
core migrated up to: 013_220_to_230 (executed)
migrating acl on database 'kong'...
acl migrated up to: 000_base_acl (executed)
acl migrated up to: 002_130_to_140 (executed)
acl migrated up to: 003_200_to_210 (executed)
acl migrated up to: 004_212_to_213 (executed)
migrating acme on database 'kong'...
acme migrated up to: 000_base_acme (executed)
migrating basic-auth on database 'kong'...
basic-auth migrated up to: 000_base_basic_auth (executed)
basic-auth migrated up to: 002_130_to_140 (executed)
basic-auth migrated up to: 003_200_to_210 (executed)
migrating bot-detection on database 'kong'...
bot-detection migrated up to: 001_200_to_210 (executed)
migrating hmac-auth on database 'kong'...
hmac-auth migrated up to: 000_base_hmac_auth (executed)
hmac-auth migrated up to: 002_130_to_140 (executed)
hmac-auth migrated up to: 003_200_to_210 (executed)
migrating ip-restriction on database 'kong'...
ip-restriction migrated up to: 001_200_to_210 (executed)
migrating jwt on database 'kong'...
jwt migrated up to: 000_base_jwt (executed)
jwt migrated up to: 002_130_to_140 (executed)
jwt migrated up to: 003_200_to_210 (executed)
migrating key-auth on database 'kong'...
key-auth migrated up to: 000_base_key_auth (executed)
key-auth migrated up to: 002_130_to_140 (executed)
key-auth migrated up to: 003_200_to_210 (executed)
migrating oauth2 on database 'kong'...
oauth2 migrated up to: 000_base_oauth2 (executed)
oauth2 migrated up to: 003_130_to_140 (executed)
oauth2 migrated up to: 004_200_to_210 (executed)
oauth2 migrated up to: 005_210_to_211 (executed)
migrating rate-limiting on database 'kong'...
rate-limiting migrated up to: 000_base_rate_limiting (executed)
rate-limiting migrated up to: 003_10_to_112 (executed)
rate-limiting migrated up to: 004_200_to_210 (executed)
migrating response-ratelimiting on database 'kong'...
response-ratelimiting migrated up to: 000_base_response_rate_limiting (executed)
migrating session on database 'kong'...
session migrated up to: 000_base_session (executed)
session migrated up to: 001_add_ttl_index (executed)
41 migrations processed
41 executed
Database is up-to-date
启动:shell>kong start
Kong startedshell>ps -ef |grep nginx
root      8212     1  0 16:34 ?        00:00:00 nginx: master process /usr/local/openresty/nginx/sbin/nginx -p /usr/local/kong -c nginx.conf
kong      8213  8212  0 16:34 ?        00:00:00 nginx: worker process
kong      8214  8212  0 16:34 ?        00:00:00 nginx: worker process
kong      8215  8212  0 16:34 ?        00:00:00 nginx: worker process
kong      8216  8212  0 16:34 ?        00:00:00 nginx: worker process
root      8260  1732  0 16:34 pts/0    00:00:00 grep --color=auto nginx

安装konga
(1)安装node.js环境

安装konga之前我们先安装一下node.js环境,

$ cd /opt/
$ wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
$ tar xf node-v10.16.0-linux-x64.tar.xz
$ mv node-v10.16.0-linux-x64 /usr/local/node

# 验证安装有效性

$ node -v
$ npm -v

#安装pm2
npm  install -g pm2
环境变量:

## set node env
export NODE=/usr/local/node
export PATH=$PATH:$NODE/bin

(2)开始安装

$ cd /home/data
$ git clone https://github.com/pantsel/konga.git --depth=1
#替换源
$ echo "registry = https://registry.npm.taobao.org" > ~/.npmrc
$ cd konga
# 安装npm 依赖
$ npm i

自己部署 Docker Kong相关推荐

  1. centos7+ docker1.12 实践部署docker及配置direct_lvm

    2019独角兽企业重金招聘Python工程师标准>>> centos7+ docker1.12 实践部署docker及配置direct_lvm 博客分类: docker 前言 Doc ...

  2. kali2.0部署docker

    测试环境 系统:Kali2.0 x64 参考链接 http://blog.csdn.net/u013814153/article/details/53925790 开始部署 Docker需要Linux ...

  3. 离线手动部署docker镜像仓库——harbor仓库(二)

    前言: 在<离线手动部署docker镜像仓库--harbor仓库(一)>中,记录了离线部署harbor仓库的简单过程,这里主要记录修改默认访问端口80端口为1180端口的部署方式和注意点. ...

  4. dotNet Core 3.1 使用 Aspose (部署 Docker)

    在之前的文章<dotNET Core中使用Aspose(部署Docker)>中介绍了在 dotNet Core2.1 中使用 Aspose ,并部署到 Docker 中,现在 dotNET ...

  5. 阿里云部署Docker(5)----管理和公布您的镜像

    出到这节,我在百度搜索了一下"阿里云部署Docker",突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的.所以,我最终明确为什么那 ...

  6. k8s dashboard_windows10 部署 docker+k8s 集群

    下面是经过踩坑之后的 windows10 单机部署 docker k8s 步骤,其中有几处比较关键的地方需要注意,后面加粗标注,下面就开始吧! 0.下载cmder 在 windows 上有一个趁手的命 ...

  7. 服务器部署docker

    服务器部署docker docker简介## 可以把docker是一个容器,可以让开发者将自己的项目部署到这个容器中,最常用的场景是将自己的后端项目部署到服务器的时候会将其打入docker镜像中,可以 ...

  8. 自动/持续部署Docker 的tomcat web项目(二)

    自动/持续部署Docker 的tomcat web项目(二) 安装jenkins Jenkins环境配置 创建Jenkins任务 源码拉取 maven构建 SSH连接 一键构建 脚本自动/持续部署 续 ...

  9. 自动/持续部署Docker 的tomcat web项目(一)

    自动/持续部署Docker 的tomcat web项目 docker安装tomcat 拉取Tomcat镜像 查看镜像 启动tomcat镜像 参数说明 查看正在运行的容器 部署web项目 编辑Docke ...

最新文章

  1. CentOS 7 解决丢失 nginx.pid
  2. BO QUERY BUILDER - SI_INSTANCE相关属性
  3. react 项目 测试
  4. 网上找的一段代码突然爆了,项目出现大Bug!
  5. android TabHost
  6. 随机存取存储器(RAM)的最大特点是什么?
  7. YARN工作流程详解
  8. unity制作子弹击砖块过程分析
  9. 笔记本电脑分区后怎么恢复?3个方法
  10. jsp医疗报销管理系统 myeclipse开发技术 mysql数据库
  11. linux grep命令要查找的内容有双引号
  12. 数学 立方和公式 立方差公式
  13. iOS 保存图片到手机的几种方法--(OC)
  14. 第101个五四青年节节目观后感
  15. 【每日更新 Suggest 】leetcode解题
  16. redis连接出错 ERR AUTH <password> called without any password configured for the default user.
  17. 怎么运行php格式的文件
  18. 8.编写一个除法计算器,程序具有try-catch-finally结构,程序要求用户输入除数和被除数,在出现除数为零(异常2)和除数、被除数中有一个不是数字(异常1)的情况时进行相应的处理。当调用存放
  19. java实现蓝牙通信程序_Android蓝牙通信聊天实现发送和接受功能
  20. 腾讯电脑管家网址认证服务 定位行业平台

热门文章

  1. 诚之和:年轻人追捧的自拍馆,为何迎来倒闭潮?
  2. Qt QScrollArea
  3. 为农田解渴为人民群众解忧 国稻种芯-桃源:湖南坚守抗旱一线
  4. SEO学习心得:分享总结学习SEO的心得
  5. 八大排序之归并排序(建议与快排一起看)
  6. 最新wordpress黑金壁纸微信小程序 二开修复版源码下载
  7. 【QQ聊天界面-创建自定义Cell Objective-C语言】
  8. 微信朋友圈如何批量发圈
  9. elasticsearch-rest-high-level-client操作elasticsearch
  10. 动态服务器原理,什么叫cdn动态加速原理