How do I put storage quota limitation on storage class

10/3/2019

I want to dynamically create PeristentVolumes and mount them into my pod using PVCs. SO, I am following kubernetes Dynamic Provisioning concept. I am creating PersistentVolumeClaim using Kubernetes StorageClasses.

I am creating PVC using StorageClasses like this.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-pvc
  namespace: test
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: test-sc
  resources:
    requests:
      storage: 100M

Now, I want to put restriction on StorageClasses test-sc to limit storage usage. In any case, the sum of storage used by PVCs which are created using StorageClass test-sc across all namespaces should not exceed 150M.

I am able to limit the storage usage of PVCs created using StorageClass test-sc for single namespace as following.

apiVersion: v1
kind: ResourceQuota
metadata:
  name: quota-limit-sc
  namespace: test
spec:
  hard:
    secure-maprfs.storageclass.storage.k8s.io/requests.storage: 150Mi

How do I put this limitation on Cluster Level i.e. on Storage Classes ??

-- Pradeep Kumar
kubernetes
kubernetes-pvc
quota

1 Answer

10/4/2019

This is applicable per namespace only. You will have to define quotas for all your namespaces

-- Mr.Axe
Source: StackOverflow