<p>We are using NFS volume (GCP filestore with 1TB size) to set RWX Many access PVC in GCP, the problem here is:
for example I allot a PVC of 5Gi and mount it to a nginx pod under /etc/nginx/test-pvc, instead of just allotting 5Gi it allots the whole NFS volume size.</p>
<p>I logged into the nginx pod and did a df -kh:</p>
<pre><code>df -kh
Filesystem           Size  Used Avail Use% Mounted on
overlay               95G   16G   79G  17% /
tmpfs                 64M     0   64M   0% /dev
tmpfs                 63G     0   63G   0% /sys/fs/cgroup
shm                   64M     0   64M   0% /dev/shm
/dev/sda1             95G   16G   79G  17% /etc/hosts
10.x.10.x:/vol 1007G  5.0M  956G   1% /etc/nginx/test-pvc
tmpfs                 63G   12K   63G   1% /run/secrets/kubernetes.io/serviceaccount
tmpfs                 63G     0   63G   0% /proc/acpi
tmpfs                 63G     0   63G   0% /proc/scsi
tmpfs                 63G     0   63G   0% /sys/firmware
</code></pre>
<p>size of /etc/nginx/test-pvc is 1007G, which is my whole volume size in NFS(1 TB), it should have been 5G instead, even the used space 5MB isn't actually used in /etc/nginx/test-pvc. Why is the behaviour so ?</p>
<p>PV and PVC yaml used:</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs-test
spec:
  capacity:
    storage: 5Gi 
  accessModes:
  - ReadWriteOnce 
  nfs: 
    path: /vol
    server: 10.x.10.x
  persistentVolumeReclaimPolicy: Recycle 


apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-claim1
spec:
  accessModes:
    - ReadWriteOnce 
  storageClassName: &quot;&quot;
  resources:
    requests:
      storage: 5Gi
  volumeName: pv-nfs-test
</code></pre>
<p>Nginx deployment yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-pv-demo-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-pv-demo
  template:
    metadata:
      name: nfs-pv-pod
      labels:
        app: nfs-pv-demo
    spec:
      containers:
      - image: nginx
        name: nfs-pv-multi
        imagePullPolicy: Always
        name: ng
        volumeMounts:
          - name: nfs-volume-1
            mountPath: &quot;/etc/nginx/test-pvc&quot;
      volumes:
      - name: nfs-volume-1
        persistentVolumeClaim:
          claimName: nfs-claim1
</code></pre>
<p>Is there anything I'm missing ? Or is this the behaviour of NFS ? If so what is the best way to handle it in production, as we will have multiple other PVCs and could cause some confusions and volume denial issues.</p>

<blockquote>
<p>Is there anything I'm missing ? Or is this the behaviour of NFS ?</p>
</blockquote>
<p>No, nothing at all. This is simply the way it works. And it's nothing specific to NFS either.</p>
<p><code>5Gi</code> of storage capacity defined in your <code>PV</code> can be treated more like a <strong>declaration</strong> that you have a <code>PersistentVolume</code> object which has 5 gigabtes of uderlying storage. <strong>But it's nothing more than just a declaration. You can not put any constraint on your available disk capacity this way.</strong> So if you have a disk that has actually 100 gigabytes of capacity it is a good practice to declare in this field of your <code>PV</code> definition <code>100Gi</code> for the sake of consistency.</p>
<p>The storage capacity you set in your <code>PVC</code> is a bit different story. It can be understood as a <strong>minimum storage capacity that would satisfy your request for storage</strong>. So if you have let's say 3 different <code>PVs</code> which have following capacities (declared in <code>PV</code> definition, no matter what their real capacity is): <code>3Gi</code>, <code>10Gi</code> and <code>100Gi</code> and you claim for <code>5Gi</code> in your <code>PersistentVolumeClaim</code>, only 2 of them i.e. <code>10Gi</code> and <code>100Gi</code> can satisfy such request. And as I said above, it doesn't matter that the smallest one which has <code>3Gi</code> declared is in fact backed with quite a large disk which has <code>1000Gi</code>. If you defined a <code>PV</code> object which represents such disk in kubernetes environment (and makes it available to be consumed by some <code>PVC</code> and in the end by some <code>Pod</code> which uses it) and you declared that this particular <code>PV</code> has only <code>3Gi</code> of capacity, <code>PVC</code> in which you request for <code>5Gi</code> has no means to verify the actual capacity of the disk and &quot;sees&quot; such volume as the one with not enough capacity to satisfy the request made for <code>5Gi</code>.</p>
<p>To illustrate that it isn't specific to NFS, you can create a new GCE persistent disk of 100 gigabytes (e.g. via cloud console as it seems the easiest way) and then you can use such disk in a <code>PV</code> and <code>PVC</code> which in the end will be used by simple nginx pod. This is described <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/preexisting-pd#create_pv_pvc" rel="nofollow noreferrer">here</a>.</p>
<p>So you may declare in your <code>PV</code> 10Gi (in <code>PVC</code> at most 10Gi then) although your GCE persistent disk has in fact the capacity of 100 gigs. And if you connect to such pod, you won't see the declared capacity of 10Gi but the real capacity of the disk. And it's completely normal and works exactly as it was designed.</p>
<p>You may have thought that it works similar to <code>LVM</code> where you create a volume group consisting of one or more disks and than you can create as many logical volumes as your underlying capacity allows you. <code>PVs</code> in kubernetes don't allow you to do anything like this. <strong>Capacity that you &quot;set&quot; in a <code>PV</code> definition is only a declaration, not a constraint of any kind.</strong> If you need to mount separate chunks of a huge disks into different pods, you would need to divide it into partitions first and create separate <code>PV</code> objects, each one out of a single partition.</p>
