Skip to content

Commit 33dc1b0

Browse files
authored
Merge pull request #49402 from windsonsea/quotae
Fix consistency issues and use code_sample for resource-quotas
2 parents a0602e9 + 1a5f27d commit 33dc1b0

File tree

3 files changed

+74
-76
lines changed

3 files changed

+74
-76
lines changed

content/en/docs/concepts/policy/resource-quotas.md

Lines changed: 11 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Resource quotas work like this:
3636
- If creating or updating a resource violates a quota constraint, the request will fail with HTTP
3737
status code `403 FORBIDDEN` with a message explaining the constraint that would have been violated.
3838

39-
- If quota is enabled in a namespace for compute resources like `cpu` and `memory`, users must specify
39+
- If quotas are enabled in a namespace for compute resources like `cpu` and `memory`, users must specify
4040
requests or limits for those values; otherwise, the quota system may reject pod creation. Hint: Use
4141
the `LimitRanger` admission controller to force defaults for pods that make no compute resource requirements.
4242

@@ -222,8 +222,8 @@ Resources specified on the quota outside of the allowed set results in a validat
222222

223223
| Scope | Description |
224224
| ----- | ----------- |
225-
| `Terminating` | Match pods where `.spec.activeDeadlineSeconds >= 0` |
226-
| `NotTerminating` | Match pods where `.spec.activeDeadlineSeconds is nil` |
225+
| `Terminating` | Match pods where `.spec.activeDeadlineSeconds` >= `0` |
226+
| `NotTerminating` | Match pods where `.spec.activeDeadlineSeconds` is `nil` |
227227
| `BestEffort` | Match pods that have best effort quality of service. |
228228
| `NotBestEffort` | Match pods that do not have best effort quality of service. |
229229
| `PriorityClass` | Match pods that references the specified [priority class](/docs/concepts/scheduling-eviction/pod-priority-preemption). |
@@ -308,60 +308,14 @@ works as follows:
308308
- Pods in the cluster have one of the three priority classes, "low", "medium", "high".
309309
- One quota object is created for each priority.
310310

311-
Save the following YAML to a file `quota.yml`.
311+
Save the following YAML to a file `quota.yaml`.
312312

313-
```yaml
314-
apiVersion: v1
315-
kind: List
316-
items:
317-
- apiVersion: v1
318-
kind: ResourceQuota
319-
metadata:
320-
name: pods-high
321-
spec:
322-
hard:
323-
cpu: "1000"
324-
memory: 200Gi
325-
pods: "10"
326-
scopeSelector:
327-
matchExpressions:
328-
- operator : In
329-
scopeName: PriorityClass
330-
values: ["high"]
331-
- apiVersion: v1
332-
kind: ResourceQuota
333-
metadata:
334-
name: pods-medium
335-
spec:
336-
hard:
337-
cpu: "10"
338-
memory: 20Gi
339-
pods: "10"
340-
scopeSelector:
341-
matchExpressions:
342-
- operator : In
343-
scopeName: PriorityClass
344-
values: ["medium"]
345-
- apiVersion: v1
346-
kind: ResourceQuota
347-
metadata:
348-
name: pods-low
349-
spec:
350-
hard:
351-
cpu: "5"
352-
memory: 10Gi
353-
pods: "10"
354-
scopeSelector:
355-
matchExpressions:
356-
- operator : In
357-
scopeName: PriorityClass
358-
values: ["low"]
359-
```
313+
{{% code_sample file="policy/quota.yaml" %}}
360314

361315
Apply the YAML using `kubectl create`.
362316

363317
```shell
364-
kubectl create -f ./quota.yml
318+
kubectl create -f ./quota.yaml
365319
```
366320

367321
```
@@ -405,33 +359,14 @@ pods 0 10
405359
```
406360

407361
Create a pod with priority "high". Save the following YAML to a
408-
file `high-priority-pod.yml`.
362+
file `high-priority-pod.yaml`.
409363

410-
```yaml
411-
apiVersion: v1
412-
kind: Pod
413-
metadata:
414-
name: high-priority
415-
spec:
416-
containers:
417-
- name: high-priority
418-
image: ubuntu
419-
command: ["/bin/sh"]
420-
args: ["-c", "while true; do echo hello; sleep 10;done"]
421-
resources:
422-
requests:
423-
memory: "10Gi"
424-
cpu: "500m"
425-
limits:
426-
memory: "10Gi"
427-
cpu: "500m"
428-
priorityClassName: high
429-
```
364+
{{% code_sample file="policy/high-priority-pod.yaml" %}}
430365

431366
Apply it with `kubectl create`.
432367

433368
```shell
434-
kubectl create -f ./high-priority-pod.yml
369+
kubectl create -f ./high-priority-pod.yaml
435370
```
436371

437372
Verify that "Used" stats for "high" priority quota, `pods-high`, has changed and that
@@ -550,9 +485,9 @@ metadata:
550485
spec:
551486
hard:
552487
requests.cpu: "1"
553-
requests.memory: 1Gi
488+
requests.memory: "1Gi"
554489
limits.cpu: "2"
555-
limits.memory: 2Gi
490+
limits.memory: "2Gi"
556491
requests.nvidia.com/gpu: 4
557492
EOF
558493
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: high-priority
5+
spec:
6+
containers:
7+
- name: high-priority
8+
image: ubuntu
9+
command: ["/bin/sh"]
10+
args: ["-c", "while true; do echo hello; sleep 10;done"]
11+
resources:
12+
requests:
13+
memory: "10Gi"
14+
cpu: "500m"
15+
limits:
16+
memory: "10Gi"
17+
cpu: "500m"
18+
priorityClassName: high

content/en/examples/policy/quota.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: v1
2+
kind: List
3+
items:
4+
- apiVersion: v1
5+
kind: ResourceQuota
6+
metadata:
7+
name: pods-high
8+
spec:
9+
hard:
10+
cpu: "1000"
11+
memory: "200Gi"
12+
pods: "10"
13+
scopeSelector:
14+
matchExpressions:
15+
- operator: In
16+
scopeName: PriorityClass
17+
values: ["high"]
18+
- apiVersion: v1
19+
kind: ResourceQuota
20+
metadata:
21+
name: pods-medium
22+
spec:
23+
hard:
24+
cpu: "10"
25+
memory: "20Gi"
26+
pods: "10"
27+
scopeSelector:
28+
matchExpressions:
29+
- operator: In
30+
scopeName: PriorityClass
31+
values: ["medium"]
32+
- apiVersion: v1
33+
kind: ResourceQuota
34+
metadata:
35+
name: pods-low
36+
spec:
37+
hard:
38+
cpu: "5"
39+
memory: "10Gi"
40+
pods: "10"
41+
scopeSelector:
42+
matchExpressions:
43+
- operator: In
44+
scopeName: PriorityClass
45+
values: ["low"]

0 commit comments

Comments
 (0)