1、部署
1.1postgres 部署
这里使用docker
docker run --name postgres -e POSTGRES_PASSWORD=123456 --net=host -p 5432:5432 -d postgres:latest
部署好后,创建kuma 数据库。
1.2 Kuma 安装
Universal Mode
下载并解压缩
curl -L https://kuma.io/installer.sh | sh -
tar xvzf kuma-*.tar.gz
运行
cd kuma-1.1.6/bin
最好使用nohup 启动。
#使用默认存储
nohup ./kuma-cp run > runoob.log 2>&1 &
#使用pG
KUMA_STORE_TYPE=postgres \
KUMA_STORE_POSTGRES_HOST=10.20.2.152 \
KUMA_STORE_POSTGRES_PORT=5432 \
KUMA_STORE_POSTGRES_USER=postgres \
KUMA_STORE_POSTGRES_PASSWORD=123456 \
KUMA_STORE_POSTGRES_DB_NAME=kuma \ nohup ./kuma-cp run > kuma.log &
netstat -tunpl |grep kuma
1.3 关于Envoy
Envoy 是专为大型现代 SOA(面向服务架构)架构设计的 L7 代理和通信总线。该项目源于以下理念:
网络对应用程序来说应该是透明的。当网络和应用程序出现问题时,应该很容易确定问题的根源
中文介绍
https://www.servicemesher.com/envoy/intro/what_is_envoy.html
英文使用手册地址:
https://www.envoyproxy.io/docs/envoy/latest/operations/admin
2、Kuma 使用
2.1管理页面
https://kuma.io/docs/1.1.6/installation/centos/
这是个只读的管理页面,没有办法设置执行kumactl 命令,但是借助这个工具可以生成 kumactl 命令,这里使用默认的Mesh,创建 一个spring boot gateway 的用例。
进入管理首页,选择GateWay
选择默认的Mesh
创建mysql的Dataplane
得到配置命令
创建 mysql 的 Mesh
最好都是用nohup的启动方式。
---查看Envoy 是否启动
curl -s http://193.168.1.127:30001/config_dump| jq -r '.configs[] | .["@type"]'
[root@localhost bin]# curl -s http://localhost:30001/config_dump | jq -r '.configs[] | .["@type"]'
type.googleapis.com/envoy.admin.v3.BootstrapConfigDump
type.googleapis.com/envoy.admin.v3.ClustersConfigDump
type.googleapis.com/envoy.admin.v3.ListenersConfigDump
type.googleapis.com/envoy.admin.v3.ScopedRoutesConfigDump
type.googleapis.com/envoy.admin.v3.RoutesConfigDump
type.googleapis.com/envoy.admin.v3.SecretsConfigDump
3、异常处理:
如果提示某个端口被占用:说明 13306 端口的envoy 代理还在启动中,如图
cannot bind '193.168.1.127:13306': Address already in use
netstat -tunpl |grep 13306
目前kuma-dp
没有stop 命令,只能kill 掉。
kill -9 26065
如果提示:kuma:envoy:admin: cannot bind '193.168.1.127:30004': Address already in use, 说明Envoy Admin API 端口冲突。
kuma-dp
是建立再在Envoy上的,Envoy 也有一套的Api,
https://www.envoyproxy.io/docs/envoy/latest/operations/admin。kuma-dp在启动Envoy 的时候,Envoy Admin API也会占用一个端口。这时候如果出现了端口冲突,要关掉无用端口,要么指定新的端口
- you can change the default port range by using --admin-port=10000-20000
- you can narrow it down to a single port by using --admin-port=9901
- you can turn Envoy Admin API off by using --admin-port=
这里建议先关掉 无用的端口:
关掉之前可以看下Envoy 的配置,确定是否可用,如果不可用可以关掉
curl -s http://localhost:30001/config_dump | jq -r '.configs[] | .["@type"]'
kill -9 31848
curl -s http://193.168.1.127:30001/config_dump
其他查看配置的方法
Envoy
简单的运维命令:
curl http://localhost:30001/get
curl http://localhost:30001/quitquitquit
ps -ef |grep envoy
[root@localhost bin]# ps -ef |grep envoy
root 1493 1483 0 15:16 pts/0 00:00:00 [envoy] <defunct>
root 3132 3122 0 15:29 pts/0 00:00:07 /home/kuma-1.1.6/bin/envoy -c /tmp/kuma-dp-100885787/bootstrap.yaml --drain-time-s 30 --disable-hot-restart -l info --bootstrap-version 3