You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: content/en/docs/concepts/policy/resource-quotas.md
+252
Original file line number
Diff line number
Diff line change
@@ -228,6 +228,7 @@ Resources specified on the quota outside of the allowed set results in a validat
228
228
|`NotBestEffort`| Match pods that do not have best effort quality of service. |
229
229
|`PriorityClass`| Match pods that references the specified [priority class](/docs/concepts/scheduling-eviction/pod-priority-preemption). |
230
230
|`CrossNamespacePodAffinity`| Match pods that have cross-namespace pod [(anti)affinity terms](/docs/concepts/scheduling-eviction/assign-pod-node). |
231
+
|`VolumeAttributesClass`| Match persistentvolumeclaims that references the specified [volume attributes class](/docs/concepts/storage/volume-attributes-classes). |
231
232
232
233
The `BestEffort` scope restricts a quota to tracking the following resource:
233
234
@@ -459,6 +460,257 @@ With the above configuration, pods can use `namespaces` and `namespaceSelector`
459
460
if the namespace where they are created have a resource quota object with
460
461
`CrossNamespacePodAffinity`scope and a hard limit greater than or equal to the number of pods using those fields.
PersistentVolumeClaims can be created with a specific [volume attributes class](/docs/concepts/storage/volume-attributes-classes/), and might be modified after creation. You can control a PVC's consumption of storage resources based on the associated volume attributes classes, by using the `scopeSelector` field in the quota spec.
468
+
469
+
The PVC references the associated volume attributes class by the following fields:
A quota is matched and consumed only if `scopeSelector` in the quota spec selects the PVC.
476
+
477
+
When the quota is scoped for the volume attributes class using the `scopeSelector` field, the quota object is restricted to track only the following resources:
478
+
479
+
* `persistentvolumeclaims`
480
+
* `requests.storage`
481
+
482
+
This example creates a quota object and matches it with PVC at specific volume attributes classes. The example works as follows:
483
+
484
+
- PVCs in the cluster have at least one of the three volume attributes classes, "gold", "silver", "copper".
485
+
- One quota object is created for each volume attributes class.
486
+
487
+
Save the following YAML to a file `quota-vac.yaml`.
488
+
489
+
{{% code_sample file="policy/quota-vac.yaml" %}}
490
+
491
+
Apply the YAML using `kubectl create`.
492
+
493
+
```shell
494
+
kubectl create -f ./quota-vac.yaml
495
+
```
496
+
497
+
```
498
+
resourcequota/pvcs-gold created
499
+
resourcequota/pvcs-silver created
500
+
resourcequota/pvcs-copper created
501
+
```
502
+
503
+
Verify that `Used` quota is `0` using `kubectl describe quota`.
504
+
505
+
```shell
506
+
kubectl describe quota
507
+
```
508
+
509
+
```
510
+
Name: pvcs-gold
511
+
Namespace: default
512
+
Resource Used Hard
513
+
-------- ---- ----
514
+
persistentvolumeclaims 0 10
515
+
requests.storage 0 10Gi
516
+
517
+
518
+
Name: pvcs-silver
519
+
Namespace: default
520
+
Resource Used Hard
521
+
-------- ---- ----
522
+
persistentvolumeclaims 0 10
523
+
requests.storage 0 20Gi
524
+
525
+
526
+
Name: pvcs-copper
527
+
Namespace: default
528
+
Resource Used Hard
529
+
-------- ---- ----
530
+
persistentvolumeclaims 0 10
531
+
requests.storage 0 30Gi
532
+
```
533
+
534
+
Create a pvc with volume attributes class "gold". Save the following YAML to a file `gold-vac-pvc.yaml`.
Verify that "Used" stats for "silver" volume attributes class quota, `pvcs-silver` has changed, `pvcs-copper` is unchanged, and `pvcs-gold` might be unchanged or released, which depends on the PVC's status.
Verify that "Used" stats for "copper" volume attributes class quota, `pvcs-copper` has changed, `pvcs-silver` and `pvcs-gold` might be unchanged or released, which depends on the PVC's status.
619
+
620
+
```shell
621
+
kubectl describe quota
622
+
```
623
+
624
+
```
625
+
Name: pvcs-gold
626
+
Namespace: default
627
+
Resource Used Hard
628
+
-------- ---- ----
629
+
persistentvolumeclaims 1 10
630
+
requests.storage 2Gi 10Gi
631
+
632
+
633
+
Name: pvcs-silver
634
+
Namespace: default
635
+
Resource Used Hard
636
+
-------- ---- ----
637
+
persistentvolumeclaims 1 10
638
+
requests.storage 2Gi 20Gi
639
+
640
+
641
+
Name: pvcs-copper
642
+
Namespace: default
643
+
Resource Used Hard
644
+
-------- ---- ----
645
+
persistentvolumeclaims 1 10
646
+
requests.storage 2Gi 30Gi
647
+
```
648
+
649
+
Print the manifest of the PVC using the following command:
650
+
651
+
```shell
652
+
kubectl get pvc gold-vac-pvc -o yaml
653
+
```
654
+
655
+
It might show the following output:
656
+
657
+
```yaml
658
+
apiVersion: v1
659
+
kind: PersistentVolumeClaim
660
+
metadata:
661
+
name: gold-vac-pvc
662
+
spec:
663
+
accessModes:
664
+
- ReadWriteOnce
665
+
resources:
666
+
requests:
667
+
storage: 2Gi
668
+
storageClassName: default
669
+
volumeAttributesClassName: copper
670
+
status:
671
+
accessModes:
672
+
- ReadWriteOnce
673
+
capacity:
674
+
storage: 2Gi
675
+
currentVolumeAttributesClassName: gold
676
+
phase: Bound
677
+
modifyVolumeStatus:
678
+
status: InProgress
679
+
targetVolumeAttributesClassName: silver
680
+
storageClassName: default
681
+
```
682
+
683
+
Wait a moment for the volume modification to complete, then verify the quota again.
684
+
685
+
```shell
686
+
kubectl describe quota
687
+
```
688
+
689
+
```
690
+
Name: pvcs-gold
691
+
Namespace: default
692
+
Resource Used Hard
693
+
-------- ---- ----
694
+
persistentvolumeclaims 0 10
695
+
requests.storage 0 10Gi
696
+
697
+
698
+
Name: pvcs-silver
699
+
Namespace: default
700
+
Resource Used Hard
701
+
-------- ---- ----
702
+
persistentvolumeclaims 0 10
703
+
requests.storage 0 20Gi
704
+
705
+
706
+
Name: pvcs-copper
707
+
Namespace: default
708
+
Resource Used Hard
709
+
-------- ---- ----
710
+
persistentvolumeclaims 1 10
711
+
requests.storage 2Gi 30Gi
712
+
```
713
+
462
714
## Requests compared to Limits {#requests-vs-limits}
463
715
464
716
When allocating compute resources, each container may specify a request and a limit value for either CPU or memory.
0 commit comments