Skip to content

Commit 6f5dd30

Browse files
committed
[zh] Update policy/resource-quotas.md
1 parent 99d7743 commit 6f5dd30

File tree

3 files changed

+80
-83
lines changed

3 files changed

+80
-83
lines changed

content/zh-cn/docs/concepts/policy/resource-quotas.md

Lines changed: 17 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ api_metadata:
66
content_type: concept
77
weight: 20
88
---
9-
109
<!--
1110
reviewers:
1211
- derekwaynecarr
@@ -54,7 +53,7 @@ Resource quotas work like this:
5453
tracks usage to ensure it does not exceed hard resource limits defined in a ResourceQuota.
5554
- If creating or updating a resource violates a quota constraint, the request will fail with HTTP
5655
status code `403 FORBIDDEN` with a message explaining the constraint that would have been violated.
57-
- If quota is enabled in a namespace for compute resources like `cpu` and `memory`, users must specify
56+
- If quotas are enabled in a namespace for compute resources like `cpu` and `memory`, users must specify
5857
requests or limits for those values; otherwise, the quota system may reject pod creation. Hint: Use
5958
the `LimitRanger` admission controller to force defaults for pods that make no compute resource requirements.
6059
@@ -405,9 +404,9 @@ exhausts the cluster's supply of Pod IPs.
405404
从而耗尽集群所能提供的 Pod IP 地址。
406405

407406
<!--
408-
您可以在[查看和设置配额](#viewing-and-setting-quotas) 上找到更多示例。
407+
You can find more examples on [Viewing and Setting Quotas](#viewing-and-setting-quotas).
409408
-->
410-
你可以在[查看和设置配额](#viewing-and-setting-quotas)节查看更多示例
409+
你可以在[查看和设置配额](#viewing-and-setting-quotas)一节查看更多示例
411410

412411
<!--
413412
## Quota Scopes
@@ -429,9 +428,9 @@ Resources specified on the quota outside of the allowed set results in a validat
429428

430429
<!--
431430
| Scope | Description |
432-
| ----- | ------------ |
433-
| `Terminating` | Match pods where `.spec.activeDeadlineSeconds >= 0` |
434-
| `NotTerminating` | Match pods where `.spec.activeDeadlineSeconds is nil` |
431+
| ----- | ----------- |
432+
| `Terminating` | Match pods where `.spec.activeDeadlineSeconds` >= `0` |
433+
| `NotTerminating` | Match pods where `.spec.activeDeadlineSeconds` is `nil` |
435434
| `BestEffort` | Match pods that have best effort quality of service. |
436435
| `NotBestEffort` | Match pods that do not have best effort quality of service. |
437436
| `PriorityClass` | Match pods that references the specified [priority class](/docs/concepts/scheduling-eviction/pod-priority-preemption). |
@@ -538,7 +537,7 @@ Pod 可以创建为特定的[优先级](/zh-cn/docs/concepts/scheduling-eviction
538537
<!--
539538
A quota is matched and consumed only if `scopeSelector` in the quota spec selects the pod.
540539
-->
541-
仅当配额规范中的 `scopeSelector` 字段选择到某 Pod 时,配额机制才会匹配和计量 Pod 的资源消耗。
540+
仅当配额规约中的 `scopeSelector` 字段选择到某 Pod 时,配额机制才会匹配和计量 Pod 的资源消耗。
542541

543542
<!--
544543
When quota is scoped for priority class using `scopeSelector` field, quota object
@@ -572,65 +571,19 @@ works as follows:
572571
- 为每个优先级创建一个配额对象。
573572

574573
<!--
575-
Save the following YAML to a file `quota.yml`.
574+
Save the following YAML to a file `quota.yaml`.
576575
-->
577-
将以下 YAML 保存到文件 `quota.yml` 中。
576+
将以下 YAML 保存到文件 `quota.yaml` 中。
578577

579-
```yaml
580-
apiVersion: v1
581-
kind: List
582-
items:
583-
- apiVersion: v1
584-
kind: ResourceQuota
585-
metadata:
586-
name: pods-high
587-
spec:
588-
hard:
589-
cpu: "1000"
590-
memory: 200Gi
591-
pods: "10"
592-
scopeSelector:
593-
matchExpressions:
594-
- operator: In
595-
scopeName: PriorityClass
596-
values: ["high"]
597-
- apiVersion: v1
598-
kind: ResourceQuota
599-
metadata:
600-
name: pods-medium
601-
spec:
602-
hard:
603-
cpu: "10"
604-
memory: 20Gi
605-
pods: "10"
606-
scopeSelector:
607-
matchExpressions:
608-
- operator: In
609-
scopeName: PriorityClass
610-
values: ["medium"]
611-
- apiVersion: v1
612-
kind: ResourceQuota
613-
metadata:
614-
name: pods-low
615-
spec:
616-
hard:
617-
cpu: "5"
618-
memory: 10Gi
619-
pods: "10"
620-
scopeSelector:
621-
matchExpressions:
622-
- operator: In
623-
scopeName: PriorityClass
624-
values: ["low"]
625-
```
578+
{{% code_sample file="policy/quota.yaml" %}}
626579

627580
<!--
628581
Apply the YAML using `kubectl create`.
629582
-->
630583
使用 `kubectl create` 命令运行以下操作。
631584

632585
```shell
633-
kubectl create -f ./quota.yml
586+
kubectl create -f ./quota.yaml
634587
```
635588

636589
```
@@ -678,39 +631,20 @@ pods 0 10
678631

679632
<!--
680633
Create a pod with priority "high". Save the following YAML to a
681-
file `high-priority-pod.yml`.
634+
file `high-priority-pod.yaml`.
682635
-->
683636
创建优先级为 "high" 的 Pod。
684-
将以下 YAML 保存到文件 `high-priority-pod.yml` 中。
637+
将以下 YAML 保存到文件 `high-priority-pod.yaml` 中。
685638

686-
```yaml
687-
apiVersion: v1
688-
kind: Pod
689-
metadata:
690-
name: high-priority
691-
spec:
692-
containers:
693-
- name: high-priority
694-
image: ubuntu
695-
command: ["/bin/sh"]
696-
args: ["-c", "while true; do echo hello; sleep 10;done"]
697-
resources:
698-
requests:
699-
memory: "10Gi"
700-
cpu: "500m"
701-
limits:
702-
memory: "10Gi"
703-
cpu: "500m"
704-
priorityClassName: high
705-
```
639+
{{% code_sample file="policy/high-priority-pod.yaml" %}}
706640

707641
<!--
708642
Apply it with `kubectl create`.
709643
-->
710644
使用 `kubectl create` 运行以下操作。
711645

712646
```shell
713-
kubectl create -f ./high-priority-pod.yml
647+
kubectl create -f ./high-priority-pod.yaml
714648
```
715649

716650
<!--
@@ -877,9 +811,9 @@ metadata:
877811
spec:
878812
hard:
879813
requests.cpu: "1"
880-
requests.memory: 1Gi
814+
requests.memory: "1Gi"
881815
limits.cpu: "2"
882-
limits.memory: 2Gi
816+
limits.memory: "2Gi"
883817
requests.nvidia.com/gpu: 4
884818
EOF
885819
```
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
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)