kubernetesazure-aksazure-disk

Attach new azure disk volume per pod in Kubernetes deployment


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:

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.


Solution

  • 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

    ✌️