<p>I'm running a single master/node Kubernetes in a Virtual Machine, using <code>hostPath</code> as a persistent volume for a deployed Postgres database.</p>

<p>My <code>PersistentVolume</code> has the following configs:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    volume.beta.kubernetes.io/storage-class: postgres
  labels:
    type: local
  name: postgres-storage
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: /data/postgres
</code></pre>

<p><em>Also, I have a <code>PersistentVolumeClaim</code> currently bounded to that volume, requesting all the capacity (<code>spec.resources.requests.storage: 1Gi</code></em>).</p>

<p>Recently, the Postgres database exceeded the <code>spec.capacity.storage</code> in size, however, without causing any problems:</p>

<pre><code>$ du -hs /data/postgres # Powers of 1024
1.2G    /data/postgres 

$ du -hs /data/postgres --si # Powers of 1000
1.3G    /data/postgres 
</code></pre>

<p><strong>My question is:</strong></p>

<ul>
<li>The <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#capacity" rel="nofollow noreferrer"><code>spec.capacity.storage</code></a> really matters when using a <code>hostPath</code>
volume, or the volume is in fact caped by the underlying partition
size?</li>
<li>What should happen when the volume usage exceeds his <code>capacity</code>? (i.e., how Kubernetes will handle this)</li>
</ul>

Eduardo Baitello
<p>According to @wongma7 on the Kubernetes GitHub page: </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>You can find the original discussion <a href="https://github.com/kubernetes/kubernetes/issues/48701" rel="nofollow noreferrer">here</a>.</p>

<p>Also, it's covered in the official <a href="https://v1-14.docs.kubernetes.io/docs/concepts/storage/volumes/#resources" rel="nofollow noreferrer">Volume/Resources</a> documentation:</p>

<blockquote>
  <p><strong>There is no limit on how much space an <code>emptyDir</code> or <code>hostPath</code> volume can
  consume</strong>, and no isolation between Containers or between Pods.</p>
  
  <p>In the future, we expect that emptyDir and hostPath volumes will be
  able to request a certain amount of space using a resource
  specification, and to select the type of media to use, for clusters
  that have several media types.</p>
</blockquote>
