自己部署 Docker Kong
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相关推荐
- centos7+ docker1.12 实践部署docker及配置direct_lvm
2019独角兽企业重金招聘Python工程师标准>>> centos7+ docker1.12 实践部署docker及配置direct_lvm 博客分类: docker 前言 Doc ...
- kali2.0部署docker
测试环境 系统:Kali2.0 x64 参考链接 http://blog.csdn.net/u013814153/article/details/53925790 开始部署 Docker需要Linux ...
- 离线手动部署docker镜像仓库——harbor仓库(二)
前言: 在<离线手动部署docker镜像仓库--harbor仓库(一)>中,记录了离线部署harbor仓库的简单过程,这里主要记录修改默认访问端口80端口为1180端口的部署方式和注意点. ...
- dotNet Core 3.1 使用 Aspose (部署 Docker)
在之前的文章<dotNET Core中使用Aspose(部署Docker)>中介绍了在 dotNet Core2.1 中使用 Aspose ,并部署到 Docker 中,现在 dotNET ...
- 阿里云部署Docker(5)----管理和公布您的镜像
出到这节,我在百度搜索了一下"阿里云部署Docker",突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的.所以,我最终明确为什么那 ...
- k8s dashboard_windows10 部署 docker+k8s 集群
下面是经过踩坑之后的 windows10 单机部署 docker k8s 步骤,其中有几处比较关键的地方需要注意,后面加粗标注,下面就开始吧! 0.下载cmder 在 windows 上有一个趁手的命 ...
- 服务器部署docker
服务器部署docker docker简介## 可以把docker是一个容器,可以让开发者将自己的项目部署到这个容器中,最常用的场景是将自己的后端项目部署到服务器的时候会将其打入docker镜像中,可以 ...
- 自动/持续部署Docker 的tomcat web项目(二)
自动/持续部署Docker 的tomcat web项目(二) 安装jenkins Jenkins环境配置 创建Jenkins任务 源码拉取 maven构建 SSH连接 一键构建 脚本自动/持续部署 续 ...
- 自动/持续部署Docker 的tomcat web项目(一)
自动/持续部署Docker 的tomcat web项目 docker安装tomcat 拉取Tomcat镜像 查看镜像 启动tomcat镜像 参数说明 查看正在运行的容器 部署web项目 编辑Docke ...
最新文章
- 立体显示与BCN双稳态手性向列相
- 差分 c语言,c语言 bmp位图差分
- RabbitMQ安装和运行
- 【Android 逆向】Android 逆向通用工具开发 ( Android 平台运行的 cmd 程序类型 | Android 平台运行的 cmd 程序编译选项 | 编译 cmd 可执行程序 )
- python自动创建目录_python自动目录环境
- 03 ORA系列:ORA-00942 表或视图不存在 table or view does not exist
- flink sql的datastream与dataset初始化代码汇总
- JS调用PHP 和 PHP调用JS的方法举例
- Neo4j配置安装与测试
- python正则表达式提取c语言中的函数,Python正则表达式匹配C语言函数
- JSP程序设计之(1)Tomcat安装及环境变量配置
- 浅谈Web身份识别技术 —— Cookie、Session 和 Token
- 游戏命中判定:圆桌算法和程序实现
- 工作总结02(海报上传模块)
- 百度小程序SEO指南
- 微信公众号自动回复服务器数据,[终极方案]解决微信公众号服务器配置启用后无法自动回...
- jq bind命名空间
- umi 如何配置webpack_umi+dva开发环境+经常使用配置和webpack配置
- 南邮计算机实验报告合集【非常全】
- 2022年吉林省高职单招(职业倾向性)考试强化训练及答案