强制 Kubernetes 分派所有请求 Pods
Force Kubernetes to dispatch request over all Pods
对于我的一个项目,我正在 Kubernetes 上部署应用程序。
简要说明一下,该应用程序(在我的开发机器中)部署在节点内的 8 pods(1 / cpu 核心)上。
每个 pod 一次可以处理一个请求(我用线程池强制限制 - CPU 是这里的瓶颈)。
我想强制 Kubernetes 负载均衡器在 pod 为 "busy" 时将传入请求发送到下一个 pod。
你们知道如何实现吗?
您可以 运行 IPVS 模式下的 Kube-proxy,它允许基于几种不同算法的服务路由。您可以在 documentation here, and this blog 中找到更多信息。来自博客:
- 您将需要 运行 带有标志的 Kube 代理
--proxy-mode=ipvs
并添加一个标志--ipvs-scheduler
用于选择其中一个选项
rr: round-robin
lc: least connection
dh: destination hashing
sh: source hashing
sed: shortest expected delay
nq: never queue
作为先决条件,节点需要安装以下模块:
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
如果你想做比这更复杂的路由 - 那么我会考虑将服务网格作为一个选项
对于我的一个项目,我正在 Kubernetes 上部署应用程序。
简要说明一下,该应用程序(在我的开发机器中)部署在节点内的 8 pods(1 / cpu 核心)上。 每个 pod 一次可以处理一个请求(我用线程池强制限制 - CPU 是这里的瓶颈)。
我想强制 Kubernetes 负载均衡器在 pod 为 "busy" 时将传入请求发送到下一个 pod。
你们知道如何实现吗?
您可以 运行 IPVS 模式下的 Kube-proxy,它允许基于几种不同算法的服务路由。您可以在 documentation here, and this blog 中找到更多信息。来自博客:
- 您将需要 运行 带有标志的 Kube 代理
--proxy-mode=ipvs
并添加一个标志
--ipvs-scheduler
用于选择其中一个选项rr: round-robin
lc: least connection
dh: destination hashing
sh: source hashing
sed: shortest expected delay
nq: never queue
作为先决条件,节点需要安装以下模块:
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
如果你想做比这更复杂的路由 - 那么我会考虑将服务网格作为一个选项