<p>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 <strong>new</strong> empty <a href="https://kubernetes.io/docs/concepts/storage/volumes/#azuredisk" rel="nofollow noreferrer">azureDisk</a> storage to be mounted into each pod/replica created in this deployment.</p>
<p>Basically I have the following restrictions:</p>
<ul>
<li>I must use Deployment, not a Statefulset</li>
<li>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.</li>
<li>the pods do not share their storage, each pod has its own 7GB storage.</li>
<li>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.</li>
</ul>
<p>When using azureDisk, I need to use it with Access mode type ReadWriteOnce (as says in the <a href="https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv" rel="nofollow noreferrer">docs</a> ) 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?</p>
<p>NOTE 1: I know there is a volumeClaimTemplates, but that's only related to a Statefulset.</p>
<p>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.</p>

<p>I'm not sure why you need to use a StatefulSet but the only I see to do this is to create your own <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/operator/" rel="nofollow noreferrer">operator</a> for your application. The operator would have a controller that manages your pods similar to what a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/" rel="nofollow noreferrer">ReplicaSet</a> does but with the exception that for every new pod that is instantiated a new PVC is created.</p>
<p>It might just be better to figure out how to run your application in a StatefulSet and use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-storage" rel="nofollow noreferrer">VolumeClaimTemplates</a></p>
<p>✌️</p>
