[zh] Fix links/translation in concepts section (7)
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
---
|
||||
approvers:
|
||||
- derekwaynecarr
|
||||
title: 资源配额
|
||||
content_type: concept
|
||||
weight: 10
|
||||
---
|
||||
|
||||
<!--
|
||||
---
|
||||
reviewers:
|
||||
- derekwaynecarr
|
||||
title: Resource Quotas
|
||||
content_type: concept
|
||||
weight: 10
|
||||
---
|
||||
-->
|
||||
|
||||
<!-- overview -->
|
||||
@@ -21,17 +17,13 @@ weight: 10
|
||||
<!--
|
||||
When several users or teams share a cluster with a fixed number of nodes,
|
||||
there is a concern that one team could use more than its fair share of resources.
|
||||
|
||||
Resource quotas are a tool for administrators to address this concern.
|
||||
-->
|
||||
当多个用户或团队共享具有固定节点数目的集群时,人们会担心有人使用超过其基于公平原则所分配到的资源量。
|
||||
|
||||
<!--
|
||||
Resource quotas are a tool for administrators to address this concern.
|
||||
-->
|
||||
资源配额是帮助管理员解决这一问题的工具。
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- body -->
|
||||
|
||||
<!--
|
||||
@@ -40,7 +32,8 @@ aggregate resource consumption per namespace. It can limit the quantity of obje
|
||||
be created in a namespace by type, as well as the total amount of compute resources that may
|
||||
be consumed by resources in that project.
|
||||
-->
|
||||
资源配额,通过 `ResourceQuota` 对象来定义,对每个命名空间的资源消耗总量提供限制。它可以限制命名空间中某种类型的对象的总数目上限,也可以限制命令空间中的 Pod 可以使用的计算资源的总上限。
|
||||
资源配额,通过 `ResourceQuota` 对象来定义,对每个命名空间的资源消耗总量提供限制。
|
||||
它可以限制命名空间中某种类型的对象的总数目上限,也可以限制命令空间中的 Pod 可以使用的计算资源的总上限。
|
||||
|
||||
<!--
|
||||
Resource quotas work like this:
|
||||
@@ -60,13 +53,26 @@ Resource quotas work like this:
|
||||
the `LimitRanger` admission controller to force defaults for pods that make no compute resource requirements.
|
||||
See the [walkthrough](/docs/tasks/administer-cluster/quota-memory-cpu-namespace/) for an example of how to avoid this problem.
|
||||
-->
|
||||
- 不同的团队可以在不同的命名空间下工作,目前这是非约束性的,在未来的版本中可能会通过 ACL (Access Control List 访问控制列表) 来实现强制性约束。
|
||||
- 不同的团队可以在不同的命名空间下工作,目前这是非约束性的,在未来的版本中可能会通过
|
||||
ACL (Access Control List 访问控制列表) 来实现强制性约束。
|
||||
- 集群管理员可以为每个命名空间创建一个或多个资源配额对象。
|
||||
- 当用户在命名空间下创建资源(如 Pod、Service 等)时,Kubernetes 的配额系统会跟踪集群的资源使用情况,以确保使用的资源用量不超过资源配额中定义的硬性资源限额。
|
||||
- 如果资源创建或者更新请求违反了配额约束,那么该请求会报错(HTTP 403 FORBIDDEN),并在消息中给出有可能违反的约束。
|
||||
- 如果命名空间下的计算资源 (如 `cpu` 和 `memory`)的配额被启用,则用户必须为这些资源设定请求值(request)和约束值(limit),否则配额系统将拒绝 Pod 的创建。
|
||||
- 当用户在命名空间下创建资源(如 Pod、Service 等)时,Kubernetes 的配额系统会
|
||||
跟踪集群的资源使用情况,以确保使用的资源用量不超过资源配额中定义的硬性资源限额。
|
||||
- 如果资源创建或者更新请求违反了配额约束,那么该请求会报错(HTTP 403 FORBIDDEN),
|
||||
并在消息中给出有可能违反的约束。
|
||||
- 如果命名空间下的计算资源 (如 `cpu` 和 `memory`)的配额被启用,则用户必须为
|
||||
这些资源设定请求值(request)和约束值(limit),否则配额系统将拒绝 Pod 的创建。
|
||||
提示: 可使用 `LimitRanger` 准入控制器来为没有设置计算资源需求的 Pod 设置默认值。
|
||||
若想避免这类问题,请参考[演练](/docs/tasks/administer-cluster/quota-memory-cpu-namespace/)中的示例。
|
||||
|
||||
若想避免这类问题,请参考
|
||||
[演练](/zh/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)示例。
|
||||
|
||||
<!--
|
||||
The name of a `ResourceQuota` object must be a valid
|
||||
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
|
||||
-->
|
||||
ResouorceQuota 对象的名称必须时合法的
|
||||
[DNS 子域名](/zh/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)。
|
||||
|
||||
<!--
|
||||
Examples of policies that could be created using namespaces and quotas are:
|
||||
@@ -79,31 +85,31 @@ Examples of policies that could be created using namespaces and quotas are:
|
||||
- Limit the "testing" namespace to using 1 core and 1GiB RAM. Let the "production" namespace
|
||||
use any amount.
|
||||
-->
|
||||
- 在具有 32 GiB 内存和 16 核 CPU 资源的集群中,允许 A 团队使用 20 GiB 内存 和 10 核的 CPU 资源,允许 B 团队使用 10 GiB 内存和 4 核的 CPU 资源,并且预留 2 GiB 内存和 2 核的 CPU 资源供将来分配。
|
||||
- 在具有 32 GiB 内存和 16 核 CPU 资源的集群中,允许 A 团队使用 20 GiB 内存 和 10 核的 CPU 资源,
|
||||
允许 B 团队使用 10 GiB 内存和 4 核的 CPU 资源,并且预留 2 GiB 内存和 2 核的 CPU 资源供将来分配。
|
||||
- 限制 "testing" 命名空间使用 1 核 CPU 资源和 1GiB 内存。允许 "production" 命名空间使用任意数量。
|
||||
|
||||
<!--
|
||||
In the case where the total capacity of the cluster is less than the sum of the quotas of the namespaces,
|
||||
there may be contention for resources. This is handled on a first-come-first-served basis.
|
||||
|
||||
Neither contention nor changes to quota will affect already created resources.
|
||||
-->
|
||||
在集群容量小于各命名空间配额总和的情况下,可能存在资源竞争。资源竞争时,Kubernetes 系统会遵循先到先得的原则。
|
||||
|
||||
<!--
|
||||
Neither contention nor changes to quota will affect already created resources.
|
||||
-->
|
||||
不管是资源竞争还是配额的修改,都不会影响已经创建的资源使用对象。
|
||||
|
||||
<!--
|
||||
## Enabling Resource Quota
|
||||
|
||||
Resource Quota support is enabled by default for many Kubernetes distributions. It is
|
||||
enabled when the apiserver `-enable-admission-plugins=` flag has `ResourceQuota` as
|
||||
one of its arguments.
|
||||
-->
|
||||
## 启用资源配额
|
||||
|
||||
<!--
|
||||
Resource Quota support is enabled by default for many Kubernetes distributions. It is
|
||||
enabled when the apiserver `--enable-admission-plugins=` flag has `ResourceQuota` as
|
||||
one of its arguments.
|
||||
-->
|
||||
资源配额的支持在很多 Kubernetes 版本中是默认开启的。当 apiserver `--enable-admission-plugins=` 参数中包含 `ResourceQuota` 时,资源配额会被启用。
|
||||
资源配额的支持在很多 Kubernetes 版本中是默认开启的。当 apiserver `--enable-admission-plugins=`
|
||||
参数中包含 `ResourceQuota` 时,资源配额会被启用。
|
||||
|
||||
<!--
|
||||
A resource quota is enforced in a particular namespace when there is a
|
||||
@@ -113,13 +119,14 @@ A resource quota is enforced in a particular namespace when there is a
|
||||
|
||||
<!--
|
||||
## Compute Resource Quota
|
||||
|
||||
You can limit the total sum of [compute resources](/docs/concepts/configuration/manage-resources-containers/) that can be requested in a given namespace.
|
||||
-->
|
||||
## 计算资源配额
|
||||
|
||||
<!--
|
||||
You can limit the total sum of [compute resources](/docs/user-guide/compute-resources) that can be requested in a given namespace.
|
||||
-->
|
||||
用户可以对给定命名空间下的可被请求的[计算资源](/docs/user-guide/compute-resources)总量进行限制。
|
||||
用户可以对给定命名空间下的可被请求的
|
||||
[计算资源](/zh/docs/concepts/configuration/manage-resources-containers/)
|
||||
总量进行限制。
|
||||
|
||||
<!--
|
||||
The following resource types are supported:
|
||||
@@ -128,14 +135,14 @@ The following resource types are supported:
|
||||
|
||||
<!--
|
||||
| Resource Name | Description |
|
||||
| --------------------- | ----------------------------------------------------------- |
|
||||
| --------------------- | --------------------------------------------------------- |
|
||||
| `limits.cpu` | Across all pods in a non-terminal state, the sum of CPU limits cannot exceed this value. |
|
||||
| `limits.memory` | Across all pods in a non-terminal state, the sum of memory limits cannot exceed this value. |
|
||||
| `requests.cpu` | Across all pods in a non-terminal state, the sum of CPU requests cannot exceed this value. |
|
||||
| `requests.memory` | Across all pods in a non-terminal state, the sum of memory requests cannot exceed this value. |
|
||||
-->
|
||||
| 资源名称 | 描述 |
|
||||
| --------------------- | ----------------------------------------------------------- |
|
||||
| --------------------- | --------------------------------------------- |
|
||||
| `limits.cpu` | 所有非终止状态的 Pod,其 CPU 限额总量不能超过该值。 |
|
||||
| `limits.memory` | 所有非终止状态的 Pod,其内存限额总量不能超过该值。 |
|
||||
| `requests.cpu` | 所有非终止状态的 Pod,其 CPU 需求总量不能超过该值。 |
|
||||
@@ -143,21 +150,23 @@ The following resource types are supported:
|
||||
|
||||
<!--
|
||||
### Resource Quota For Extended Resources
|
||||
-->
|
||||
### 扩展资源的资源配额
|
||||
|
||||
<!--
|
||||
In addition to the resources mentioned above, in release 1.10, quota support for
|
||||
[extended resources](/docs/concepts/configuration/manage-compute-resources-container/#extended-resources) is added.
|
||||
-->
|
||||
除上述资源外,在 Kubernetes 1.10 版本中,还添加了对[扩展资源](/zh/docs/concepts/configuration/manage-resources-containers/#扩展资源-extended-resources)的支持。
|
||||
### 扩展资源的资源配额
|
||||
|
||||
除上述资源外,在 Kubernetes 1.10 版本中,还添加了对
|
||||
[扩展资源](/zh/docs/concepts/configuration/manage-resources-containers/#extended-resources)
|
||||
的支持。
|
||||
|
||||
<!--
|
||||
As overcommit is not allowed for extended resources, it makes no sense to specify both `requests`
|
||||
and `limits` for the same extended resource in a quota. So for extended resources, only quota items
|
||||
with prefix `requests.` is allowed for now.
|
||||
-->
|
||||
由于扩展资源不可超量分配,因此没有必要在配额中为同一扩展资源同时指定 `requests` 和 `limits`。对于扩展资源而言,目前仅允许使用前缀为 `requests.` 的配额项。
|
||||
由于扩展资源不可超量分配,因此没有必要在配额中为同一扩展资源同时指定 `requests` 和 `limits`。
|
||||
对于扩展资源而言,目前仅允许使用前缀为 `requests.` 的配额项。
|
||||
|
||||
<!--
|
||||
Take the GPU resource as an example, if the resource name is `nvidia.com/gpu`, and you want to
|
||||
@@ -174,22 +183,20 @@ See [Viewing and Setting Quotas](#viewing-and-setting-quotas) for more detail in
|
||||
|
||||
<!--
|
||||
## Storage Resource Quota
|
||||
|
||||
You can limit the total sum of [storage resources](/docs/concepts/storage/persistent-volumes/) that can be requested in a given namespace.
|
||||
|
||||
In addition, you can limit consumption of storage resources based on associated storage-class.
|
||||
-->
|
||||
## 存储资源配额
|
||||
|
||||
<!--
|
||||
You can limit the total sum of [storage resources](/docs/concepts/storage/persistent-volumes/) that can be requested in a given namespace.
|
||||
-->
|
||||
用户可以对给定命名空间下的[存储资源](/docs/user-guide/persistent-volumes)总量进行限制。
|
||||
用户可以对给定命名空间下的[存储资源](/zh/docs/concepts/storage/persistent-volumes/)总量进行限制。
|
||||
|
||||
<!--
|
||||
In addition, you can limit consumption of storage resources based on associated storage-class.
|
||||
-->
|
||||
此外,还可以根据相关的存储类(Storage Class)来限制存储资源的消耗。
|
||||
|
||||
<!--
|
||||
| Resource Name | Description |
|
||||
| --------------------- | ----------------------------------------------------------- |
|
||||
| --------------------- | --------------------------------------------------------- |
|
||||
| `requests.storage` | Across all persistent volume claims, the sum of storage requests cannot exceed this value. |
|
||||
| `persistentvolumeclaims` | The total number of [persistent volume claims](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) that can exist in the namespace. |
|
||||
| `<storage-class-name>.storageclass.storage.k8s.io/requests.storage` | Across all persistent volume claims associated with the storage-class-name, the sum of storage requests cannot exceed this value. |
|
||||
@@ -198,9 +205,9 @@ In addition, you can limit consumption of storage resources based on associated
|
||||
| 资源名称 | 描述 |
|
||||
| --------------------- | ----------------------------------------------------------- |
|
||||
| `requests.storage` | 所有 PVC,存储资源的需求总量不能超过该值。 |
|
||||
| `persistentvolumeclaims` | 在该命名空间中所允许的 [PVC](/docs/user-guide/persistent-volumes/#persistentvolumeclaims) 总量。 |
|
||||
| `persistentvolumeclaims` | 在该命名空间中所允许的 [PVC](/zh/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) 总量。 |
|
||||
| `<storage-class-name>.storageclass.storage.k8s.io/requests.storage` | 在所有与 storage-class-name 相关的持久卷声明中,存储请求的总和不能超过该值。 |
|
||||
| `<storage-class-name>.storageclass.storage.k8s.io/persistentvolumeclaims` | 在与 storage-class-name 相关的所有持久卷声明中,命名空间中可以存在的[持久卷声明](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)总数。 |
|
||||
| `<storage-class-name>.storageclass.storage.k8s.io/persistentvolumeclaims` | 在与 storage-class-name 相关的所有持久卷声明中,命名空间中可以存在的[持久卷申领](/zh/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)总数。 |
|
||||
|
||||
<!--
|
||||
For example, if an operator wants to quota storage with `gold` storage class separate from `bronze` storage class, the operator can
|
||||
@@ -229,12 +236,11 @@ In release 1.8, quota support for local ephemeral storage is added as an alpha f
|
||||
|
||||
<!--
|
||||
## Object Count Quota
|
||||
|
||||
The 1.9 release added support to quota all standard namespaced resource types using the following syntax:
|
||||
-->
|
||||
## 对象数量配额
|
||||
|
||||
<!--
|
||||
The 1.9 release added support to quota all standard namespaced resource types using the following syntax:
|
||||
-->
|
||||
Kubernetes 1.9 版本增加了使用以下语法对所有标准的、命名空间域的资源类型进行配额设置的支持。
|
||||
|
||||
* `count/<resource>.<group>`
|
||||
@@ -263,7 +269,6 @@ For example, to create a quota on a `widgets` custom resource in the `example.co
|
||||
Kubernetes 1.15 版本增加了对使用相同语法来约束自定义资源的支持。
|
||||
例如,要对 `example.com` API 组中的自定义资源 `widgets` 设置配额,请使用 `count/widgets.example.com`。
|
||||
|
||||
|
||||
<!--
|
||||
When using `count/*` resource quota, an object is charged against the quota if it exists in server storage.
|
||||
These types of quotas are useful to protect against exhaustion of storage resources. For example, you may
|
||||
@@ -278,18 +283,17 @@ a poorly configured cronjob creating too many jobs in a namespace causing a deni
|
||||
<!--
|
||||
Prior to the 1.9 release, it was possible to do generic object count quota on a limited set of resources.
|
||||
In addition, it is possible to further constrain quota for particular resources by their type.
|
||||
|
||||
The following types are supported:
|
||||
-->
|
||||
在 Kubernetes 1.9 版本之前,可以在有限的一组资源上实施一般性的对象数量配额。
|
||||
此外,还可以进一步按资源的类型设置其配额。
|
||||
|
||||
<!--
|
||||
The following types are supported:
|
||||
-->
|
||||
支持以下类型:
|
||||
|
||||
<!--
|
||||
| Resource Name | Description |
|
||||
| ------------------------------- | ------------------------------------------------- |
|
||||
| ----------------------------|--------------------------------------------- |
|
||||
| `configmaps` | The total number of config maps that can exist in the namespace. |
|
||||
| `persistentvolumeclaims` | The total number of [persistent volume claims](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) that can exist in the namespace. |
|
||||
| `pods` | The total number of pods in a non-terminal state that can exist in the namespace. A pod is in a terminal state if `.status.phase in (Failed, Succeeded)` is true. |
|
||||
@@ -303,10 +307,10 @@ The following types are supported:
|
||||
| 资源名称 | 描述 |
|
||||
| ------------------------------- | ------------------------------------------------- |
|
||||
| `configmaps` | 在该命名空间中允许存在的 ConfigMap 总数上限。 |
|
||||
| `persistentvolumeclaims` | 在该命名空间中允许存在的 [PVC](/docs/user-guide/persistent-volumes/#persistentvolumeclaims) 的总数上限。 |
|
||||
| `persistentvolumeclaims` | 在该命名空间中允许存在的 [PVC](/zh/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) 的总数上限。 |
|
||||
| `pods` | 在该命名空间中允许存在的非终止状态的 pod 总数上限。Pod 终止状态等价于 Pod 的 `.status.phase in (Failed, Succeeded)` = true |
|
||||
| `replicationcontrollers` | 在该命名空间中允许存在的 RC 总数上限。 |
|
||||
| `resourcequotas` | 在该命名空间中允许存在的[资源配额](/docs/admin/admission-controllers/#resourcequota)总数上限。 |
|
||||
| `resourcequotas` | 在该命名空间中允许存在的资源配额总数上限。 |
|
||||
| `services` | 在该命名空间中允许存在的 Service 总数上限。 |
|
||||
| `services.loadbalancers` | 在该命名空间中允许存在的 LoadBalancer 类型的服务总数上限。 |
|
||||
| `services.nodeports` | 在该命名空间中允许存在的 NodePort 类型的服务总数上限。 |
|
||||
@@ -318,18 +322,19 @@ created in a single namespace that are not terminal. You might want to set a `po
|
||||
quota on a namespace to avoid the case where a user creates many small pods and
|
||||
exhausts the cluster's supply of Pod IPs.
|
||||
-->
|
||||
例如,`pods` 配额统计某个命名空间中所创建的、非终止状态的 `Pod` 个数并确保其不超过某上限值。用户可能希望在某命名空间中设置 `pods` 配额,以避免有用户创建很多小的 Pod,从而耗尽集群所能提供的 Pod IP 地址。
|
||||
例如,`pods` 配额统计某个命名空间中所创建的、非终止状态的 `Pod` 个数并确保其不超过某上限值。
|
||||
用户可能希望在某命名空间中设置 `pods` 配额,以避免有用户创建很多小的 Pod,从而耗尽集群所能提供的 Pod IP 地址。
|
||||
|
||||
<!--
|
||||
## Quota Scopes
|
||||
-->
|
||||
## 配额作用域
|
||||
|
||||
<!--
|
||||
Each quota can have an associated set of scopes. A quota will only measure usage for a resource if it matches
|
||||
the intersection of enumerated scopes.
|
||||
-->
|
||||
每个配额都有一组相关的作用域(scope),配额只会对作用域内的资源生效。配额机制仅统计所列举的作用域的交集中的资源用量。
|
||||
## 配额作用域 {#quota-scopes}
|
||||
|
||||
每个配额都有一组相关的作用域(scope),配额只会对作用域内的资源生效。
|
||||
配额机制仅统计所列举的作用域的交集中的资源用量。
|
||||
|
||||
<!--
|
||||
When a scope is added to the quota, it limits the number of resources it supports to those that pertain to the scope.
|
||||
@@ -340,7 +345,7 @@ Resources specified on the quota outside of the allowed set results in a validat
|
||||
|
||||
<!--
|
||||
| Scope | Description |
|
||||
| ----- | ----------- |
|
||||
| ----- | ------------ |
|
||||
| `Terminating` | Match pods where `.spec.activeDeadlineSeconds >= 0` |
|
||||
| `NotTerminating` | Match pods where `.spec.activeDeadlineSeconds is nil` |
|
||||
| `BestEffort` | Match pods that have best effort quality of service. |
|
||||
@@ -355,12 +360,11 @@ Resources specified on the quota outside of the allowed set results in a validat
|
||||
|
||||
<!--
|
||||
The `BestEffort` scope restricts a quota to tracking the following resource: `pods`
|
||||
|
||||
The `Terminating`, `NotTerminating`, and `NotBestEffort` scopes restrict a quota to tracking the following resources:
|
||||
-->
|
||||
`BestEffort` 作用域限制配额跟踪以下资源:`pods`
|
||||
|
||||
<!--
|
||||
The `Terminating`, `NotTerminating`, and `NotBestEffort` scopes restrict a quota to tracking the following resources:
|
||||
-->
|
||||
`Terminating`、`NotTerminating` 和 `NotBestEffort` 这三种作用域限制配额跟踪以下资源:
|
||||
|
||||
* `cpu`
|
||||
@@ -383,18 +387,17 @@ Pods can be created at a specific [priority](/docs/concepts/configuration/pod-pr
|
||||
You can control a pod's consumption of system resources based on a pod's priority, by using the `scopeSelector`
|
||||
field in the quota spec.
|
||||
-->
|
||||
Pod 可以创建为特定的[优先级](/docs/concepts/configuration/pod-priority-preemption/#pod-priority)。
|
||||
Pod 可以创建为特定的[优先级](/zh/docs/concepts/configuration/pod-priority-preemption/#pod-priority)。
|
||||
通过使用配额规约中的 `scopeSelector` 字段,用户可以根据 Pod 的优先级控制其系统资源消耗。
|
||||
|
||||
<!--
|
||||
A quota is matched and consumed only if `scopeSelector` in the quota spec selects the pod.
|
||||
-->
|
||||
仅当配额规范中的 `scopeSelector` 字段选择到某 Pod 时,配额机制才会匹配和计量 Pod 的资源消耗。
|
||||
|
||||
<!--
|
||||
This example creates a quota object and matches it with pods at specific priorities. The example
|
||||
works as follows:
|
||||
-->
|
||||
仅当配额规范中的 `scopeSelector` 字段选择到某 Pod 时,配额机制才会匹配和计量 Pod 的资源消耗。
|
||||
|
||||
本示例创建一个配额对象,并将其与具有特定优先级的 Pod 进行匹配。
|
||||
该示例的工作方式如下:
|
||||
|
||||
@@ -405,9 +408,7 @@ works as follows:
|
||||
- 集群中的 Pod 可取三个优先级类之一,即 "low"、"medium"、"high"。
|
||||
- 为每个优先级创建一个配额对象。
|
||||
|
||||
<!--
|
||||
Save the following YAML to a file `quota.yml`.
|
||||
-->
|
||||
<!-- Save the following YAML to a file `quota.yml`. -->
|
||||
将以下 YAML 保存到文件 `quota.yml` 中。
|
||||
|
||||
```yaml
|
||||
@@ -467,7 +468,7 @@ Apply the YAML using `kubectl create`.
|
||||
kubectl create -f ./quota.yml
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
resourcequota/pods-high created
|
||||
resourcequota/pods-medium created
|
||||
resourcequota/pods-low created
|
||||
@@ -482,7 +483,7 @@ Verify that `Used` quota is `0` using `kubectl describe quota`.
|
||||
kubectl describe quota
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
Name: pods-high
|
||||
Namespace: default
|
||||
Resource Used Hard
|
||||
@@ -557,7 +558,7 @@ the other two quotas are unchanged.
|
||||
kubectl describe quota
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
Name: pods-high
|
||||
Namespace: default
|
||||
Resource Used Hard
|
||||
@@ -597,13 +598,12 @@ pods 0 10
|
||||
|
||||
<!--
|
||||
## Requests vs Limits
|
||||
-->
|
||||
## 请求与限制
|
||||
|
||||
<!--
|
||||
When allocating compute resources, each container may specify a request and a limit value for either CPU or memory.
|
||||
The quota can be configured to quota either value.
|
||||
-->
|
||||
## 请求与限制 {#requests-vs-limits}
|
||||
|
||||
分配计算资源时,每个容器可以为 CPU 或内存指定请求和约束。
|
||||
配额可以针对二者之一进行设置。
|
||||
|
||||
@@ -612,16 +612,16 @@ If the quota has a value specified for `requests.cpu` or `requests.memory`, then
|
||||
container makes an explicit request for those resources. If the quota has a value specified for `limits.cpu` or `limits.memory`,
|
||||
then it requires that every incoming container specifies an explicit limit for those resources.
|
||||
-->
|
||||
如果配额中指定了 `requests.cpu` 或 `requests.memory` 的值,则它要求每个容器都显式给出对这些资源的请求。同理,如果配额中指定了 `limits.cpu` 或 `limits.memory` 的值,那么它要求每个容器都显式设定对应资源的限制。
|
||||
如果配额中指定了 `requests.cpu` 或 `requests.memory` 的值,则它要求每个容器都显式给出对这些资源的请求。
|
||||
同理,如果配额中指定了 `limits.cpu` 或 `limits.memory` 的值,那么它要求每个容器都显式设定对应资源的限制。
|
||||
|
||||
<!--
|
||||
## Viewing and Setting Quotas
|
||||
|
||||
Kubectl supports creating, updating, and viewing quotas:
|
||||
-->
|
||||
## 查看和设置配额 {#viewing-and-setting-quotas}
|
||||
|
||||
<!--
|
||||
Kubectl supports creating, updating, and viewing quotas:
|
||||
-->
|
||||
Kubectl 支持创建、更新和查看配额:
|
||||
|
||||
```shell
|
||||
@@ -674,7 +674,7 @@ kubectl create -f ./object-counts.yaml --namespace=myspace
|
||||
kubectl get quota --namespace=myspace
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
NAME AGE
|
||||
compute-resources 30s
|
||||
object-counts 32s
|
||||
@@ -684,7 +684,7 @@ object-counts 32s
|
||||
kubectl describe quota compute-resources --namespace=myspace
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
Name: compute-resources
|
||||
Namespace: myspace
|
||||
Resource Used Hard
|
||||
@@ -700,7 +700,7 @@ requests.nvidia.com/gpu 0 4
|
||||
kubectl describe quota object-counts --namespace=myspace
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
Name: object-counts
|
||||
Namespace: myspace
|
||||
Resource Used Hard
|
||||
@@ -736,7 +736,7 @@ kubectl create deployment nginx --image=nginx --namespace=myspace
|
||||
kubectl describe quota --namespace=myspace
|
||||
```
|
||||
|
||||
```shell
|
||||
```
|
||||
Name: test
|
||||
Namespace: myspace
|
||||
Resource Used Hard
|
||||
@@ -749,27 +749,26 @@ count/secrets 1 4
|
||||
|
||||
<!--
|
||||
## Quota and Cluster Capacity
|
||||
-->
|
||||
## 配额和集群容量
|
||||
|
||||
<!--
|
||||
`ResourceQuotas` are independent of the cluster capacity. They are
|
||||
expressed in absolute units. So, if you add nodes to your cluster, this does *not*
|
||||
automatically give each namespace the ability to consume more resources.
|
||||
-->
|
||||
资源配额与集群资源总量是完全独立的。它们通过绝对的单位来配置。所以,为集群添加节点时,资源配额*不会*自动赋予每个命名空间消耗更多资源的能力。
|
||||
## 配额和集群容量 {#quota-and-cluster-capacity}
|
||||
|
||||
资源配额与集群资源总量是完全独立的。它们通过绝对的单位来配置。
|
||||
所以,为集群添加节点时,资源配额*不会*自动赋予每个命名空间消耗更多资源的能力。
|
||||
|
||||
<!--
|
||||
Sometimes more complex policies may be desired, such as:
|
||||
-->
|
||||
有时可能需要资源配额支持更复杂的策略,比如:
|
||||
|
||||
<!--
|
||||
- Proportionally divide total cluster resources among several teams.
|
||||
- Allow each tenant to grow resource usage as needed, but have a generous
|
||||
limit to prevent accidental resource exhaustion.
|
||||
- Detect demand from one namespace, add nodes, and increase quota.
|
||||
-->
|
||||
有时可能需要资源配额支持更复杂的策略,比如:
|
||||
|
||||
- 在几个团队中按比例划分总的集群资源。
|
||||
- 允许每个租户根据需要增加资源使用量,但要有足够的限制以防止资源意外耗尽。
|
||||
- 探测某个命名空间的需求,添加物理节点并扩大资源配额值。
|
||||
@@ -779,7 +778,8 @@ Such policies could be implemented using `ResourceQuotas` as building blocks, by
|
||||
writing a "controller" that watches the quota usage and adjusts the quota
|
||||
hard limits of each namespace according to other signals.
|
||||
-->
|
||||
这些策略可以通过将资源配额作为一个组成模块、手动编写一个控制器来监控资源使用情况,并结合其他信号调整命名空间上的硬性资源配额来实现。
|
||||
这些策略可以通过将资源配额作为一个组成模块、手动编写一个控制器来监控资源使用情况,
|
||||
并结合其他信号调整命名空间上的硬性资源配额来实现。
|
||||
|
||||
<!--
|
||||
Note that resource quota divides up aggregate cluster resources, but it creates no
|
||||
@@ -789,21 +789,22 @@ restrictions around nodes: pods from several namespaces may run on the same node
|
||||
|
||||
<!--
|
||||
## Limit Priority Class consumption by default
|
||||
|
||||
It may be desired that pods at a particular priority, eg. "cluster-services", should be allowed in a namespace, if and only if, a matching quota object exists.
|
||||
-->
|
||||
## 默认情况下限制特定优先级的资源消耗
|
||||
|
||||
<!--
|
||||
It may be desired that pods at a particular priority, eg. "cluster-services", should be allowed in a namespace, if and only if, a matching quota object exists.
|
||||
-->
|
||||
有时候可能希望当且仅当某名字空间中存在匹配的配额对象时,才可以创建特定优先级(例如 "cluster-services")的 Pod。
|
||||
有时候可能希望当且仅当某名字空间中存在匹配的配额对象时,才可以创建特定优先级
|
||||
(例如 "cluster-services")的 Pod。
|
||||
|
||||
<!--
|
||||
With this mechanism, operators will be able to restrict usage of certain high priority classes to a limited number of namespaces and not every namespace will be able to consume these priority classes by default.
|
||||
-->
|
||||
通过这种机制,操作人员能够将限制某些高优先级类仅出现在有限数量的命名空间中,而并非每个命名空间默认情况下都能够使用这些优先级类。
|
||||
通过这种机制,操作人员能够将限制某些高优先级类仅出现在有限数量的命名空间中,
|
||||
而并非每个命名空间默认情况下都能够使用这些优先级类。
|
||||
|
||||
<!--
|
||||
To enforce this, kube-apiserver flag `--admission-control-config-file` should be used to pass path to the following configuration file:
|
||||
To enforce this, kube-apiserver flag `-admission-control-config-file` should be used to pass path to the following configuration file:
|
||||
-->
|
||||
要实现此目的,应使用 kube-apiserver 标志 `--admission-control-config-file` 传递如下配置文件的路径:
|
||||
|
||||
@@ -827,13 +828,13 @@ plugins:
|
||||
{{% /tab %}}
|
||||
{{% tab name="apiserver.k8s.io/v1alpha1" %}}
|
||||
```yaml
|
||||
# 在 Kubernetes 1.17 中已不被推荐使用,请使用 apiserver.config.k8s.io/v1
|
||||
# 在 Kubernetes 1.17 中已不推荐使用,请使用 apiserver.config.k8s.io/v1
|
||||
apiVersion: apiserver.k8s.io/v1alpha1
|
||||
kind: AdmissionConfiguration
|
||||
plugins:
|
||||
- name: "ResourceQuota"
|
||||
configuration:
|
||||
# 在 Kubernetes 1.17 中已不被推荐使用,请使用 apiserver.config.k8s.io/v1, ResourceQuotaConfiguration
|
||||
# 在 Kubernetes 1.17 中已不推荐使用,请使用 apiserver.config.k8s.io/v1, ResourceQuotaConfiguration
|
||||
apiVersion: resourcequota.admission.k8s.io/v1beta1
|
||||
kind: Configuration
|
||||
limitedResources:
|
||||
@@ -848,12 +849,11 @@ plugins:
|
||||
|
||||
<!--
|
||||
Now, "cluster-services" pods will be allowed in only those namespaces where a quota object with a matching `scopeSelector` is present.
|
||||
|
||||
For example:
|
||||
-->
|
||||
现在,仅当命名空间中存在匹配的 `scopeSelector` 的配额对象时,才允许使用 "cluster-services" Pod。
|
||||
|
||||
<!--
|
||||
For example:
|
||||
-->
|
||||
示例:
|
||||
|
||||
```yaml
|
||||
@@ -867,24 +867,23 @@ For example:
|
||||
<!--
|
||||
See [LimitedResources](https://github.com/kubernetes/kubernetes/pull/36765) and [Quota support for priority class design doc](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/pod-priority-resourcequota.md) for more information.
|
||||
-->
|
||||
有关更多信息,请参见 [LimitedResources](https://github.com/kubernetes/kubernetes/pull/36765) 和[优先级类配额支持的设计文档](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/pod-priority-resourcequota.md)。
|
||||
有关更多信息,请参见 [LimitedResources](https://github.com/kubernetes/kubernetes/pull/36765) 和
|
||||
[优先级类配额支持的设计文档](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/pod-priority-resourcequota.md)。
|
||||
|
||||
<!--
|
||||
## Example
|
||||
|
||||
See a [detailed example for how to use resource quota](/docs/tasks/administer-cluster/quota-api-object/).
|
||||
-->
|
||||
## 示例
|
||||
|
||||
<!--
|
||||
See a [detailed example for how to use resource quota](/docs/tasks/administer-cluster/quota-api-object/).
|
||||
-->
|
||||
查看[如何使用资源配额的详细示例](/docs/tasks/administer-cluster/quota-api-object/)。
|
||||
|
||||
|
||||
查看[如何使用资源配额的详细示例](/zh/docs/tasks/administer-cluster/quota-api-object/)。
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
|
||||
<!--
|
||||
See [ResourceQuota design doc](https://git.k8s.io/community/contributors/design-proposals/resource-management/admission_control_resource_quota.md) for more information.
|
||||
- See [ResourceQuota design doc](https://git.k8s.io/community/contributors/design-proposals/resource-management/admission_control_resource_quota.md) for more information.
|
||||
-->
|
||||
查看[资源配额设计文档](https://git.k8s.io/community/contributors/design-proposals/resource-management/admission_control_resource_quota.md)了解更多信息。
|
||||
- 查看[资源配额设计文档](https://git.k8s.io/community/contributors/design-proposals/resource-management/admission_control_resource_quota.md)
|
||||
了解更多信息。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user