【发布时间】:2020-06-08 09:44:16
【问题描述】:
情况
我想要一个 pool 的 serving 豆荚(假设我有 50 个 serving 豆荚在周围)。它们将通过 LoadBalancer 服务公开。
我想确保:
- 每个 pod 只提供一个 TCP 连接,并保持此连接处于活动状态,直到客户端终止它。在此 pod 生命周期结束之前,它不会接收任何其他 TCP 连接。
- 一旦客户端终止连接,Pod 就会自行清理并销毁它。
- 启动另一个 pod 以匹配所需的副本编号。由于它当前不提供任何 TCP 连接,因此可以选择为下一个进入 LoadBalancer 服务的 TCP 连接提供服务。
例子
1. Initially, a `Deployment` specifies a pool of 2 pods behind a LoadBalancer Service.
[1] [2]
------LoadBalancer-------
2. A client initiates a TCP connection to the LoadBalancer (e.g. telnet loadbalancer.domain.com 80) and the TCP connection is routed to the first vacant pod.
[1] [2]
|
|
------LoadBalancer-------
|
|
cl1
3. 24 hours after that (assuming data has been passing between client1 & pod1), another client hits to the same Load Balancer public domain. Since pod1 is serving client1, I want the second client to be routed to another vacant pod, such as pod 2.
[1] [2]
| |
| |
------LoadBalancer-------
| |
| |
cl1 cl2
4. 24 hours after that, client 1 terminates the connection, I want pod1 to do clean up and destroy itself shortly afterwards. No new connections should be routed to it. That leaves pod2 the only one still running.
[2]
|
|
------LoadBalancer-------
|
|
cl2
5. `Deployment` will create additional pods to ensure the number of replicas. So pod3 is created.
[1] [3]
|
|
------LoadBalancer-------
|
|
cl1
6. Another client hits the same endpoint and is routed to a vacant pod (pod 3 in this case).
[1] [3]
| |
| |
------LoadBalancer-------
| |
| |
cl1 cl3
And so on and so forth.
有人知道如何在 K8s 上解决这个问题吗?
【问题讨论】:
标签: kubernetes