简体   繁体   English

根据他们访问的数据将多个用户路由到特定的 Kubernetes pod

[英]Route multiple users to a specific Kubernetes pod based on the data they access

I have multiple pods of the same app deployed using Kubernetes.我使用 Kubernetes 部署了同一应用程序的多个 pod。 The app manages multiple 'Project' objects.该应用程序管理多个“项目”对象。 When Marry is working on 'Project 1' on pod-01, Tom logs on pod-02.当 Marry 在 pod-01 上处理“项目 1”时,Tom 登录到 pod-02。 Here is the requirement, if Tom tries to open 'Project 1' on pod-02, we need to route him to pod-01 where 'Project 1' is already open by Marry.这是要求,如果 Tom 尝试在 pod-02 上打开“项目 1”,我们需要将他路由到 pod-01,其中 Marry 已经打开了“项目 1”。 How would I do that?我该怎么做?

Can I store some unique identifier of pod-01 in the 'Project 1' object?我可以在“项目 1”object 中存储一些 pod-01 的唯一标识符吗? So I can use it to route Tom to pod-01.所以我可以用它把 Tom 路由到 pod-01。

Is this technically feasible?这在技术上可行吗?

What you are describing is stateful workload, where each instance of your application contain state .您所描述的是有状态的工作负载,您的应用程序的每个实例都包含state

Normal workload in Kubernetes is stateless and deployed with Deployment and ReplicaSet . Kubernetes 中的正常工作负载是无状态的,并使用DeploymentReplicaSet进行部署。 However, Kubernetes now has some support for stateful workloads by using StatefulSet但是,Kubernetes 现在通过使用StatefulSet有状态工作负载提供了一些支持

It may be possible to implement your use case, but it depends.有可能实现您的用例,但这取决于。 Your users will not have an instance for themself if that is what you need.如果您需要,您的用户将不会拥有自己的实例。 I would recommend you to architect your service to be stateless workload, and store all state in a database (possibly with statefulSet) since it is much easier to handle stateless workloads.我建议您将服务构建为无状态工作负载,并将所有 state 存储在数据库中(可能使用 statefulSet),因为处理无状态工作负载要容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM