简体   繁体   English

在Kubernetes的工作节点之间共享存储/卷?

[英]Share storage/volume between worker nodes in Kubernetes?

Is it possible to have a centralized storage/volume that can be shared between two pods/instances of an application that exist in different worker nodes in Kubernetes? 是否有可能在Kubernetes的不同工作程序节点中存在的应用程序的两个Pod /实例之间共享一个集中式存储/卷?

So to explain my case: 所以解释一下我的情况:

  • I have a Kubernetes cluster with 2 worker nodes. 我有一个带有2个工作节点的Kubernetes集群。 In each one of these I have 1 instance of app X running. 在每一个中,我都有1个正在运行的App X实例。 This means I have 2 instances of app X running totally at the same time. 这意味着我有两个App X实例完全同时运行。

  • Both instances subscribe on the topic topicX, that has 2 partitions, and are part of a consumer group in Apache Kafka called groupX. 这两个实例都订阅了具有两个分区的topicX主题,它们是Apache Kafka中名为groupX的使用者组的一部分。

As I understand it the message load will be split among the partitions, but also among the consumers in the consumer group. 据我了解,消息负载将在分区之间分配,但在消费者组中的消费者之间也会分配。 So far so good, right? 到目前为止一切顺利,对吗?

So to my problem: 所以对我的问题:

  • In my whole solution I have a hierarchy division with the unique constraint by country and ID. 在我的整个解决方案中,我有一个按国家和ID唯一约束的层次结构划分。 Each combination of country and ID has a pickle model (python Machine Learning Model), which is stored in a directory accessed by the application. 国家和ID的每种组合都有一个pickle模型(python机器学习模型),该模型存储在应用程序访问的目录中。 For each combination of a country and ID I receive one message per minute. 对于一个国家/地区和ID的每种组合,我每分钟都会收到一条消息。

  • At the moment I have 2 countries, so to be able to scale properly I wanted to split the load between two instances of app X, each one handling its own country. 目前,我有2个国家/地区,因此,为了能够进行适当的扩展,我想在两个应用X实例之间分配负载,每个实例处理自己的国家/地区。

  • The problem is that with Kafka the messages can be balanced between the different instances, and to access the pickle-files in each instance without know what country the message belongs to, I have to store the pickle-files in both instances. 问题在于,使用Kafka可以在不同实例之间平衡消息,并且在不知道消息属于哪个国家的情况下访问每个实例中的pickle文件时,我必须在两个实例中存储pickle文件。

Is there a way to solve this? 有办法解决吗? I would rather keep the setup as simple as possible so it is easy to scale and add a third, fourth and fifth country later. 我希望设置尽可能简单,以便在以后扩展和添加第三,第四和第五个国家时很容易。

Keep in mind that this is an overly simplified way of explaining the problem. 请记住,这是解释问题的过于简化的方法。 The number of instances is much higher in reality etc. 实际上,实例数要多得多。

Yes. 是。 It's possible if you look at this table any PV (Physical Volume) that supports ReadWriteMany will help you accomplish having the same data store for your Kafka workers. 如果您查看此表,任何支持ReadWriteMany PV (物理卷)都可以帮助您为Kafka工人完成相同的数据存储。 So in summary these: 因此,这些总结如下:

  • AzureFile Azure文件
  • CephFS 头文件
  • Glusterfs Glusterfs
  • Quobyte 兆字节
  • NFS NFS
  • VsphereVolume - (works when pods are collocated) VsphereVolume-(在吊舱并置时有效)
  • PortworxVolume Portworx卷

In my opinion, NFS is the easiest to implement. 我认为,NFS是最容易实现的。 Note that Azurefile, Quobyte, and Portworx are paid solutions. 请注意,Azurefile,Quobyte和Portworx是付费解决方案。

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

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