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

Vasu Youth
<p>According to Kubernetes Official documentation:</p>
<p><strong>Why we need to give storageClassName in PV?</strong></p>
<blockquote>
<p>Each <em>StorageClass</em> contains the fields <em>provisioner, parameters, and
reclaimPolicy</em>, which are used when a PersistentVolume belonging to
the class needs to be dynamically provisioned.</p>
<p>The name of a StorageClass object is significant, and is how users can
request a particular class. Administrators set the name and other
parameters of a class when first creating <em>StorageClass</em> objects, and
the objects cannot be updated once they are created.</p>
</blockquote>
<p><strong>When Storage class creates PV, why to give storageClassName in PV?</strong></p>
<blockquote>
<p>A PersistentVolume (PV) is a piece of storage in the cluster that has
been provisioned by an administrator or dynamically provisioned using
<em>Storage Classes</em>. It is a resource in the cluster just like a node is a cluster resource.</p>
<p>Cluster administrators need to be able to offer a variety of
PersistentVolumes that differ in more ways than size and access modes,
without exposing users to the details of how those volumes are
implemented. For these needs, there is the <em>StorageClass</em> resource.</p>
</blockquote>
<p>If you wish to know more about Storage class resources, please follow <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">this link</a>, or <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">this one</a> to know more about Persistent Volumes.</p>
