<p>I have a storage class : </p>

<pre><code>    kubectl describe storageclass my-local-storage

    Name:            my-local-storage
    IsDefaultClass:  No
    Annotations:     kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"my-local-storage"},"provisioner":"kubernetes.io/no-provisioner","volumeBindingMode":"WaitForFirstConsumer"}

    Provisioner:           kubernetes.io/no-provisioner
    Parameters:            &lt;none&gt;
    AllowVolumeExpansion:  &lt;unset&gt;
    MountOptions:          &lt;none&gt;
    ReclaimPolicy:         Delete
    VolumeBindingMode:     WaitForFirstConsumer
    Events:                &lt;none&gt;
</code></pre>

<p><strong>Peristent Volume</strong></p>

<pre><code>kubectl describe pv my-local-pv
Name:              my-local-pv
Labels:            &lt;none&gt;
Annotations:       pv.kubernetes.io/bound-by-controller: yes
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      my-local-storage
Status:            Bound
Claim:             default/my-claim
Reclaim Policy:    Retain
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          1Mi
Node Affinity:     
  Required Terms:  
    Term 0:        kubernetes.io/hostname in [kubenode2]
Message:           
Source:
    Type:  LocalVolume (a persistent volume backed by local storage on a node)
    Path:  /home/node/serviceLogsNew
Events:    &lt;none&gt;
</code></pre>

<p><strong>Persistent Volume Claim</strong></p>

<pre><code>node@kubemaster:~/Desktop$ kubectl describe pvc my-claim
Name:          my-claim
Namespace:     default
StorageClass:  my-local-storage
Status:        Bound
Volume:        my-local-pv
Labels:        &lt;none&gt;
Annotations:   pv.kubernetes.io/bind-completed: yes
               pv.kubernetes.io/bound-by-controller: yes
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      1Mi
Access Modes:  RWO
VolumeMode:    Filesystem
Mounted By:    podname-deployment-897d6947b-hnvvq
               podname-deployment-897d6947b-q4f79
Events:        &lt;none&gt;
</code></pre>

<p>Now, I have created a persistent Volume with capacity: 1Mi.</p>

<p>I am running 2 pods attached to PV using PVC. Pods are creating log files.
The size of files inside the folder (/home/node/serviceLogsNew) used for PV grows to 5 MB. Still everything is working fine.</p>

<p>So, capacity is ignored while using Local PV / PVC? Is it configurable? </p>

Ankit Bansal
<p>Please take a look at <a href="https://github.com/kubernetes/kubernetes/issues/48701" rel="noreferrer">this</a> github issue. I believe that <a href="https://github.com/kubernetes/kubernetes/issues/48701#issuecomment-314929576" rel="noreferrer">this</a> comment answers also your question:</p>

<blockquote>
  <p>this is working as intended, kube can't/won't enforce the capacity of
  PVs, the capacity field on PVs is just a label. It's up to the
  "administrator" i.e. the creator of the PV to label it accurately so
  that when users create PVCs that needs >= X Gi, they get what they
  want.</p>
</blockquote>

<p><a href="https://github.com/kubernetes/kubernetes/issues/48701#issuecomment-320375825" rel="noreferrer">This</a> advise may be also useful in your case:</p>

<blockquote>
  <p>... If you want hard capacity boundaries with hostpath, then you
  should create a partition with the size you need, or use filesystem
  quota.</p>
  
  <p>If this is just ephemeral data, then you can consider using emptyDir
  volumes. Starting in 1.7, you can specify a limit on the capacity, and
  kubelet will evict your pod if you exceed the limit.</p>
</blockquote>

<p>The person who reported the issue actually uses <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="noreferrer">hostPath</a> volume type but <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="noreferrer">local</a> works pretty much the same and same rules are applied here when it comes to setting <code>capacity</code> in <code>PV</code> definition. <strong>Kubernetes</strong> doesn't have any mechanisms which could enforce a specific disk quota on the directory you mount into your <code>Pod</code> from <code>node</code>.</p>

<p>Note that in your <code>PV</code> definition you can set a <code>capacity</code> which is much higher than the actual capacity of the underlying disk. Such <code>PV</code> will be created without any errors and will be usable allowing you to write data up to its actual maximum capacity.</p>

<p>While <code>capacity</code> in <code>PV</code> definition is just a mere lablel, with <code>PVC</code> it's a bit different story. In this context <code>capacity</code> can be interpreted as a <strong>request for a specific minimal capacity</strong>. If your storage provisioner is able to satisfy your request, the storage will be provisioned. If it's unable to give you the storage with minimal capacity defined in your claim, it won't be provisioned.</p>

<p>Let's assume you have defined a <code>PV</code> based on a specific directory on your host/node with the capacity of <code>150Gi</code>. If you define a <code>PVC</code> in which you claim for <code>151Gi</code>, the storage won't be provisioned as <code>PV</code> with the declared <code>capacity</code> (no matter if it is a real or some made up value) won't be able to satisfy the request set in our <code>PVC</code>. So in case of <code>PVC</code>, the <code>capacity</code> can be interpreted as a kind of constraint but it still can't enforce/limit the use of actually available underlying storage.</p>

<p>Don't forget that <em>a <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="noreferrer">local</a> volume represents a mounted local storage device such as <strong>a disk, partition or directory</em></strong> so it's not only the directory that you can use. It can be e.g. your <code>/dev/sdb</code> disk or <code>/dev/sda5</code> partition. You can also decide to use <strong>LVM partition with strictly defined capacity</strong>.</p>
