<p>I created PV as follows:</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: foo-pv
spec:
  storageClassName: &quot;my-storage&quot;
  claimRef:
    name: foo-pvc
    namespace: foo
</code></pre>
<p>Why we need to give storageClassName in PV? When Storage class creates PV, why to give storageClassName in PV?</p>
<p>Can someone help me to understand this?</p>

<p>You can have 2 types of PVs:</p>
<ol>
<li>dynamic provisioned by StorageClasses</li>
<li>manually/static created by admins</li>
</ol>
<p><strong>Dynamically</strong> -&gt; this is often used within cloud, for instance when you want to mount an Azure blob/file to a pod. In this case you don't have control over PV name, StorageClass create and bound random created PVs.</p>
<p><a href="https://i.stack.imgur.com/m5wOi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m5wOi.png" alt="enter image description here" /></a></p>
<p><strong>Manually</strong> -&gt; this will give more control, you can assign a specific name to PV, a specific StorageClass that has Retain policy (do not delete PV after Released by Pod). In result is much easier to reuse that PV, knowing it name and StorageClass membership.</p>
<p><a href="https://i.stack.imgur.com/rjj56.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjj56.png" alt="enter image description here" /></a></p>
