Limit Storage Consumption
The following resources are used in the demonstration: ResourceQuota, , and PersistentVolumeClaim.
The admin would like to limit:
- The number of persistent volume claims in a namespace
- The amount of storage each claim can request
- The amount of cumulative storage the namespace can have
Adding a LimitRange
to a namespace enforces storage request sizes to a minimum and maximum. Storage is requested via PersistentVolumeClaim
. The admission controller that enforces limit ranges will reject any PVC that is above or below the values set by the admin.
In this example, a PVC requesting 10Gi of storage would be rejected because it exceeds the 2Gi max.
Admins can limit the number of PVCs in a namespace as well as the cumulative capacity of those PVCs. New PVCs that exceed either maximum value will be rejected.
In this example, a 6th PVC in the namespace would be rejected because it exceeds the maximum count of 5. Alternatively, a 5Gi maximum quota when combined with the 2Gi max limit above, cannot have 3 PVCs where each has 2Gi. That would be 6Gi requested for a namespace capped at 5Gi.
kind: ResourceQuota
metadata:
spec:
hard:
requests.storage: "5Gi"
A limit range can put a ceiling on how much storage is requested while a resource quota can effectively cap the storage consumed by a namespace through claim counts and cumulative storage capacity. The allows a cluster-admin to plan their cluster’s storage budget without risk of any one project going over their allotment.