1
votes

I have a Kubernetes Deployment app with 3 replicas, which needs a 7GB storage for each replica, I want to be able to attach a new empty azureDisk storage to be mounted into each pod/replica created in this deployment.

Basically I have the following restrictions:

  • I must use Deployment, not a Statefulset
  • Each time a pod dies and a new pod is up, it shouldn't have a state, and it will have a new empty azureDisk attached to it.
  • the pods do not share their storage, each pod has its own 7GB storage.
  • the pods need to use azureDisk because I need a 7GB storage on demand, which means, dynamically creating azureStorage when I scale my deployment replicas.

When using azureDisk, I need to use it with Access mode type ReadWriteOnce (as says in the docs ) and it will attach the only 1 pod to this disk, that's found, but, that only works if I have 1 pod, if I have more than 1 pod, I can't use the same claim... is there any way to dynamically ask for more storages like the one in the first claim?

NOTE 1: I know there is a volumeClaimTemplates, but that's only related to a Statefulset.

NOTE 2: I don't care if a pod restarts 100 times, and this in turn creates 100 PV which only 1 is used, that is fine.

2
Can you clarify why do you have the requirement of using a Deployment and not a StatefulSet, which was designed to address exactly these kinds of use-cases?BogdanL

2 Answers

1
votes

I'm not sure why you need to use a StatefulSet but the only I see to do this is to create your own operator for your application. The operator would have a controller that manages your pods similar to what a ReplicaSet does but with the exception that for every new pod that is instantiated a new PVC is created.

It might just be better to figure out how to run your application in a StatefulSet and use VolumeClaimTemplates

✌️

0
votes

The main question is - Why? "if I have an application which doesn't have state, still I need a large volume for each pod"

Looking at this explanation you should focus on StateFull application. From my point of view it looks like you are forcing to use Deployment instead of StateFullSet for StateFull application

In your example probably you need pv which support different access modes.

The main problem you have experienced is that using pv with supported mode ReadWriteOnce you can bind at the same time only one pv by single node. So your pods in different nodes will not start due to failing volume mounting. You can use this approach only for ReadOnlyMany/ReadWriteMany scenario.

Please refer to other providers which have different capabilities for access modes like: filestore(gcp), AzureFile(azure), Glusterfs, NFS