Skip to content

Commit

Permalink
feat(dist): add kong note of gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Alice52 committed Oct 16, 2023
1 parent e76b3f4 commit fa0435e
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 1 deletion.
Empty file added dist/gateway/kong/1.route.md
Empty file.
Empty file added dist/gateway/kong/2.service.md
Empty file.
31 changes: 31 additions & 0 deletions dist/gateway/kong/3.upstream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[toc]

## upstream(上有服务)

1. 将流量转发到的多个 target 的集合, target 可以是域名/ip+port
2. 功能

- **负载均衡**: `基于 DNS 的负载均衡` || `Ring-balancer(环形均衡器)`
- 健康检查: 主动检查 || 被动检查, 将流量转发至其它健康的 target
- 熔断: 根据健康检查的状态, 对客户端请求进行熔断, 防止后端级联服务雪崩

## 负载均衡: [hash 一致性算法](https://mp.weixin.qq.com/s/76R-JD5zWzixrBQb6WYjXQ)

1. 轮询、加权轮询、随机选择

### DNS 负载均衡

### 环形均衡器: Ring-balancer

## 健康检查

1. 主动检查
2. 被动检查

## target

---

## reference

1. https://www.jianshu.com/p/b44400618c69
1 change: 1 addition & 0 deletions dist/gateway/kong/4.target.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[3.upstream link](./3.upstream.md)
Empty file added dist/gateway/kong/5.consumer.md
Empty file.
53 changes: 53 additions & 0 deletions dist/gateway/kong/6.plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[toc]

## plugins(kong/openresty/nginx 的精魂所在)

1. Kong 开源版本提供 8 个类型 共 28 个插件

- **身份认证类**: 只有认证后才能使用 consumer 概念
- 安全防护类
- **流量控制类**
- 云平台插件类
- 分析监控类
- 转换请求类型类
- **日志记录类**
- 其他插件类

2. 常见的插件应用

- Ip restriction: 黑白名单

1. 可以配置一个区段, 也可以是特定的 IP 地址
2. 可以针对所有的消费方, 也可以是特定的某个消费方
3. 可以针对所有的 API, 也可以针对特定的 API 接口
4. 黑白名单能同时配置并生效(docker 内可能会是 172.22.0.1)

- Oauth2: 需要 api 本身就是 https 且设置 only_https=true

1. Authorization code: 授权码模式
2. Implicit Grant: 隐式模式
3. Resource Owner Password Credentials: 密码模式
4. Client Credentials: 客户端模式

- **Jwt**
- Rate limiting: 限流请求
- request termination

1. 使用指定的状态代码和消息终止传入请求
2. 允许暂时阻止 API 或 Consumer, 但不能触发阈值自动熔断: 实际意义不大
3. 可用于发版部署的时候率先熔断服务

- File-log

1. 将请求和响应数据附加到磁盘上的日志文件
2. 指定路径为文件全路径不是目录路径

- http-log: 将请求和响应日志发送到 HTTP 服务器
- Prometheus: 监控, 公开与 Kong 和代理上游服务相关的指标
- Canary: 灰度发布

---

## reference

1. https://docs.konghq.com/hub/
4 changes: 3 additions & 1 deletion dist/gateway/01.kong.md → dist/gateway/kong/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[toc]

## intros
## intros/overview

![avatar](/static/image/dist/gateway/kong-flow.png)

## deploy

Expand Down
Binary file added static/image/dist/gateway/kong-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa0435e

Please sign in to comment.