Home > Mobile >  Difference between container disk usage stats (df) and K8 PVC Capacity
Difference between container disk usage stats (df) and K8 PVC Capacity

Time:07-01

I would like to understand the difference between PVC capacity I assigned (5G) and the container available capacity reported against the mounted volume inside the container.

  1. Have a GCE PD with 10G capacity
  2. Have a PVC with 5G capacity against the same GCE PD.
  3. However, when I run df -h inside the PVC volume mount inside a container: It shows available capacity against the volume as 9.5G.
sh-4.4$ kubectl get pvc,pv -o wide
NAME                              STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE   VOLUMEMODE
persistentvolumeclaim/nfs-claim   Bound    nfs-pv   5Gi        RWX                           17d   Filesystem

NAME                      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE   VOLUMEMODE
persistentvolume/nfs-pv   5Gi        RWX            Retain           Bound    default/nfs-claim                           17d   Filesystem
sh-4.4$ kubectl get pvc,pv -o wide
NAME                              STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE   VOLUMEMODE
persistentvolumeclaim/nfs-claim   Bound    nfs-pv   5Gi        RWX                           17d   Filesystem

NAME                      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE   VOLUMEMODE
persistentvolume/nfs-pv   5Gi        RWX            Retain           Bound    default/nfs-claim                           17d   Filesystem

Deployment PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-claim
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 5Gi

Deployment:

...
volumes:
     - name: molecule-storage
          persistentVolumeClaim:
            claimName: nfs-claim
volumeMounts:
          - name: molecule-storage
            mountPath: "/mnt/boomi"

I would expect this to be 5G as per PVC capacity instead. Any ideas?

CodePudding user response:

As confirmed by GCP Support, the reason for this PV/PVC Capacity is ignored in this case when it's an NFS mount.

CodePudding user response:

Persistent volumes can be attached to pods in a variety of ways. When you set the storage requests for dynamic provisioning to 30 Gi, GCE PD will be automatically provisioned for you with 30 Gi. However, the storage size will equal the size of the GCE PD if you opt to use the preexisting PD or static provisioning.

The PV storage capacity field is merely a label; K8s won't enforce the storage capacity. It is the implementer's responsibility to make sure that storage size and capacity are compatible.

  • Related