Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

So to explain my case:

  • I have a Kubernetes cluster with 2 worker nodes. In each one of these I have 1 instance of app X running. This means I have 2 instances of app X running totally at the same time.

  • Both instances subscribe on the topic topicX, that has 2 partitions, and are part of a consumer group in Apache Kafka called 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. Each combination of country and ID has a pickle model (python Machine Learning Model), which is stored in a directory accessed by the application. For each combination of a country and ID I receive one message per minute.

  • 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.

  • 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.

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.

like image 991
danielo Avatar asked Oct 09 '18 19:10

danielo


1 Answers

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. So in summary these:

  • AzureFile
  • CephFS
  • Glusterfs
  • Quobyte
  • NFS
  • VsphereVolume - (works when pods are collocated)
  • PortworxVolume

In my opinion, NFS is the easiest to implement. Note that Azurefile, Quobyte, and Portworx are paid solutions.

like image 138
Rico Avatar answered Nov 08 '22 12:11

Rico