<p>I have a PV <code>alpha-pv</code> in the kubernetes cluster and have created a PVC matching the PV specs. The PV uses the <code>Storage Class: slow</code>. However, when I check the existence of Storage Class in Cluster there is no Storage Class existing and still my PVC was <code>Bound</code> to the PV.</p>
<p>How is this Possible when the Storage Class referred in the PV/PVC does not exists in the cluster?</p>
<p>If I don't mention the Storage Class in PVC, I get error message stating Storage Class Set. There is already an existing PV in the cluster which has <code>RWO</code> access modes, <code>1Gi</code> storage size and with the Storage class named <code>slow</code>.  But on checking the Storage Class details, there is no Storage Class resource in cluster.</p>
<p>If I add the Storage Class name <code>slow</code> in my PVC <code>mysql-alpha-pvc</code>, then the PVC binds to the PV. But I'm not clear how this happens when the Storage Class referred in PV/PVC named <code>slow</code> doesn't exist in the cluster.</p>
<p><a href="https://i.stack.imgur.com/a0oJR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a0oJR.png" alt="Storage Class Error in PVC" /></a></p>
<p><a href="https://i.stack.imgur.com/1qCTl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1qCTl.png" alt="PVC Bound to PV even when the Storage class named &quot;slow&quot; does not exists in Cluster " /></a></p>

<h2>Short answer</h2>
<p>It depends.</p>
<h2>Theory</h2>
<p>One of the main purpose of using a <code>storageClass</code> is <a href="https://kubernetes.io/blog/2016/10/dynamic-provisioning-and-storage-in-kubernetes/" rel="nofollow noreferrer">dynamic provisioning</a>. That means that persistent volumes will be automatically provisioned once persistent volume claim requests for the storage: immediately or after pod using this <code>PVC</code> is created. See <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#volume-binding-mode" rel="nofollow noreferrer">Volume binding mode</a>.</p>
<p>Also:</p>
<blockquote>
<p>A StorageClass provides a way for administrators to describe the
&quot;classes&quot; of storage they offer. Different classes might map to
quality-of-service levels, or to backup policies, or to arbitrary
policies determined by the cluster administrators. Kubernetes itself
is unopinionated about what classes represent. This concept is
sometimes called &quot;profiles&quot; in other storage systems.</p>
</blockquote>
<p><a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#introduction" rel="nofollow noreferrer">Reference</a>.</p>
<h2>How it works</h2>
<p>If for instance kubernetes is used in cloud (Google GKE, Azure AKS or AWS EKS), they have already had predefined <code>storageClasses</code>, for example this is from Google GKE:</p>
<pre><code>$ kubectl get storageclasses
NAME                 PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
premium-rwo          pd.csi.storage.gke.io   Delete          WaitForFirstConsumer   true                   27d
standard (default)   kubernetes.io/gce-pd    Delete          Immediate              true                   27d
standard-rwo         pd.csi.storage.gke.io   Delete          WaitForFirstConsumer   true                   27d
</code></pre>
<p>So you can create <code>PVC</code>'s and refer to <code>storageClass</code>, <code>PV</code> will be created for you.</p>
<hr />
<p>Another scenario which you faced is you can create <code>PVC</code> and <code>PV</code> with any custom <code>storageClassName</code> only for binding purposes. Usually it's used for testing something locally. This is also called <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#static" rel="nofollow noreferrer">static provisioning</a>.</p>
<p>In this case you can create &quot;fake&quot; storage class which won't exist in kubernetes server.</p>
<p>Please see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">an example with such type of binding</a>:</p>
<blockquote>
<p>It defines the StorageClass name manual for the PersistentVolume,
which will be used to bind PersistentVolumeClaim requests to this
PersistentVolume.</p>
</blockquote>
<h2>Useful links:</h2>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">Kubernetes storage classes</a></li>
<li><a href="https://kubernetes.io/blog/2016/10/dynamic-provisioning-and-storage-in-kubernetes/" rel="nofollow noreferrer">Kubernetes dynamic provisioning</a></li>
<li><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Kubernetes persistent volumes</a></li>
</ul>
