ambassador 学习三 限速处理
与认证类似ambassador 也是委托给三方的其他服务进行限速处理
基本的环境安装可以参考相关文档,主要还是qotm 服务
官方参考实现的简单限速服务
---
apiVersion: v1
kind: Service
metadata:
name: example-rate-limit
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: RateLimitService
name: ratelimit
service: "example-rate-limit:5000"
spec:
type: ClusterIP
selector:
app: example-rate-limit
ports:
- port: 5000
name: http-example-rate-limit
targetPort: http-api
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example-rate-limit
spec:
replicas: 1
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: example-rate-limit
spec:
containers:
- name: example-rate-limit
image: agervais/ambassador-ratelimit-service:1.0.0
imagePullPolicy: Always
ports:
- name: http-api
containerPort: 5000
resources:
limits:
cpu: "0.1"
memory: 100Mi
kubectl apply -f example-rate-limit.yaml
部署状态
服务配置
---
apiVersion: v1
kind: Service
metadata:
name: qotm
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: qotm_mapping
prefix: /qotm/
service: qotm
rate_limits:
- descriptor: A test case
headers:
- "x-ambassador-test-allow"
spec:
type: ClusterIP
selector:
app: qotm
ports:
- port: 80
name: http-qotm
targetPort: http-api
kubectl apply -f service-config.yaml
测试服务
- 测试脚本
curl -v -H "x-ambassador-test-allow: probably" http://localhost:32190//qotm/quote/1
参考资料
https://www.getambassador.io/user-guide/rate-limiting-tutorial
https://github.com/rongfengliang/ambassador-learning
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2017-07-05 转发 Java火焰图在Netflix的实践
2017-07-05 转发 GSLB概要和实现原理
2017-07-05 通过openresty && tengine && nginx 动态添加资源到 html 页面
2015-07-05 将内网映射到外网的工具