Search code examples
kubernetespersistent-volumes

Does hotPath reserve specified amount of storage in node


I have a static PV spec, using hostPath.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysqlvol
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi #Size of the volume
  accessModes:
    - ReadWriteOnce #type of access # RWO RWX ROX
  hostPath:
    path: "/tmp/new.txt" #host location

In the node I don't see 10Gi of storage under /tmp. How is storage reserved for hostPath.

pvc spec

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysqlvol
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi # < 10Gi

pod spec

apiVersion: v1
kind: Pod
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: mysqlvol
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage

I am able to write data > 10GiB.

root@task-pv-pod:/usr/share/nginx/html# ls -lh
total 15G
-rw-r--r-- 1 root root 15G May 22 04:16 bigfile.txt
-rw-r--r-- 1 root root   3 May 18 12:04 new.txt
root@task-pv-pod:/usr/share/nginx/html#   
  1. What is the relevance of 10GiB here as I can write any amount of data in the volume [ 15GiB also works ]
  2. Why does PVC creation fail when request size is > 10GiB given the fact that volume is capable of accommodating higher size.

Solution

  • There is no storage reservation, nor quota. You declare that the volume is capable of 10GiB and when a PVC with that request is created, it is matched against the declared space.