Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,74 @@ see the [Troubleshooting](#troubleshooting) section.
但是,容器运行时不会由于 CPU 使用率过高而杀死 Pod 或容器。

要确定某容器是否会由于资源限制而无法调度或被杀死,请参阅[问题诊断](#troubleshooting)节。

<!--
### Resizing container resources

After creating a Pod, you may need to adjust its CPU or memory resources based on
actual usage patterns. Kubernetes provides two approaches for resizing Pod resources:
-->
### 调整容器资源

创建 Pod 后,你可能需要根据实际使用情况调整其 CPU 或内存资源。Kubernetes
提供了两种调整 Pod 资源大小的方法:

<!--
#### In-place resize {#pod-resize-inplace}
-->
#### 就地调整 {#pod-resize-inplace}

{{< feature-state feature_gate_name="InPlacePodVerticalScaling" >}}

<!--
You can modify the CPU and memory `requests` and `limits` of containers
in a running Pod without recreating it. This is called _in-place Pod vertical scaling_
or _in-place Pod resize_. To perform an in-place resize, update the container's resource
specifications using the Pod's `/resize` subresource. You can control whether a container
restart is required by setting the `resizePolicy` field in the container specification.
-->
你无需重新创建 Pod 即可修改正在运行的 Pod 中容器的 CPU 和内存请求及限制。
这称为 "Pod 就地垂直扩容"或 "Pod 就地调整大小"。
要执行就地调整大小,请使用 Pod 的 `/resize` 子资源更新容器的资源规约。
你可以通过设置容器规约中的 `resizePolicy` 字段来控制是否需要重启容器。

{{< note >}}
<!--
In-place resize currently applies to container-level resources. For resizing Pod-level
resources, see [Resize Pod CPU and Memory Resources](/docs/tasks/configure-pod-container/resize-pod-resources/).
-->
目前,就地调整大小仅适用于容器级别的资源。要调整 Pod 级别的资源大小,
请参阅[调整 Pod CPU 和内存资源](/zh-cn/docs/tasks/configure-pod-container/resize-pod-resources/)。
{{< /note >}}

<!--
#### Resizing by launching replacement Pods

The cloud native approach to changing a Pod's resources is to update the Pod template
in the workload object (such as a Deployment or StatefulSet) and let the workload's
controller replace Pods with new ones that have the updated resources. This approach
works with any Kubernetes version and can change any Pod specification.
-->
#### 通过启动替换 Pod 来调整 Pod 的资源

云原生方法更改 Pod 资源的方法是更新工作负载对象(例如 Deployment 或 StatefulSet)中的
Pod 模板,并让工作负载控制器将旧 Pod 替换为具有更新资源的新 Pod。
此方法适用于任何 Kubernetes 版本,并且可以更改任何 Pod 规约。

<!--
For more details about Pod resizing, see [Resizing Pods](/docs/concepts/workloads/pods/pod-lifecycle/#pod-resize).
For detailed instructions on in-place resize, see
[Resize CPU and Memory Resources assigned to Containers](/docs/tasks/configure-pod-container/resize-container-resources/).
You can also use the [Vertical Pod Autoscaler](/docs/concepts/workloads/autoscaling/vertical-pod-autoscale/)
to automatically manage Pod resource recommendations.
-->
有关 Pod 调整大小的更多详细信息,
请参阅[调整 Pod 大小](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-resize)。
有关就地调整大小的详细说明,
请参阅[调整分配给容器的 CPU 和内存资源](/zh-cn/docs/tasks/configure-pod-container/resize-container-resources/)。
你还可以使用[垂直 Pod 自动扩缩器](/zh-cn/docs/concepts/workloads/autoscaling/vertical-pod-autoscale/)来自动管理
Pod 资源建议。

<!--
### Monitoring compute & memory resource usage

Expand Down Expand Up @@ -769,7 +837,7 @@ in [scheduler configuration](/docs/reference/config-api/kube-scheduler-config.v1
#### 集群层面的扩展资源 {#cluster-level-extended-resources}

集群层面的扩展资源并不绑定到具体节点。
它们通常由调度器扩展程序(Scheduler Extenders)管理,这些程序处理资源消耗和资源配额。
它们通常由调度器扩展程序(Scheduler Extender)管理,这些程序处理资源消耗和资源配额。

你可以在[调度器配置](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1/)
中指定由调度器扩展程序处理的扩展资源。
Expand Down Expand Up @@ -985,7 +1053,32 @@ kubectl describe nodes e2e-test-node-pool-4lw4
```

<!--
```
Name: e2e-test-node-pool-4lw4
[ ... lines removed for clarity ...]
Capacity:
cpu: 2
memory: 7679792Ki
pods: 110
Allocatable:
cpu: 1800m
memory: 7474992Ki
pods: 110
[ ... lines removed for clarity ...]
Non-terminated Pods: (5 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
kube-system fluentd-gcp-v1.38-28bv1 100m (5%) 0 (0%) 200Mi (2%) 200Mi (2%)
kube-system kube-dns-3297075139-61lj3 260m (13%) 0 (0%) 100Mi (1%) 170Mi (2%)
kube-system kube-proxy-e2e-test-... 100m (5%) 0 (0%) 0 (0%) 0 (0%)
kube-system monitoring-influxdb-grafana-v4-z1m12 200m (10%) 200m (10%) 600Mi (8%) 600Mi (8%)
kube-system node-problem-detector-v0.1-fj7m3 20m (1%) 200m (10%) 20Mi (0%) 100Mi (1%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
CPU Requests CPU Limits Memory Requests Memory Limits
------------ ---------- --------------- -------------
680m (34%) 400m (20%) 920Mi (11%) 1070Mi (13%)
```
-->
```
Name: e2e-test-node-pool-4lw4
Expand Down Expand Up @@ -1032,7 +1125,7 @@ each Node has a `.status.allocatable` field
(see [NodeStatus](/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeStatus)
for details).
-->
Pods 可用的资源量低于节点的资源总量,因为系统守护进程也会使用一部分可用资源。
Pod 可用的资源量低于节点的资源总量,因为系统守护进程也会使用一部分可用资源。
在 Kubernetes API 中,每个 Node 都有一个 `.status.allocatable` 字段
(详情参见 [NodeStatus](/zh-cn/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeStatus))。

Expand Down Expand Up @@ -1158,8 +1251,10 @@ memory limit (and possibly request) for that container.
* Read more about [Quality of Service classes for Pods](/docs/concepts/workloads/pods/pod-qos/)
* Read more about [Extended Resource allocation by DRA](/docs/concepts/scheduling-eviction/dynamic-resource-allocation/#extended-resource)
-->
* 获取[分配内存资源给容器和 Pod](/zh-cn/docs/tasks/configure-pod-container/assign-memory-resource/) 的实践经验
* 获取[分配 CPU 资源给容器和 Pod](/zh-cn/docs/tasks/configure-pod-container/assign-cpu-resource/) 的实践经验
* 获取[分配内存资源给容器和 Pod](/zh-cn/docs/tasks/configure-pod-container/assign-memory-resource/)
的实践经验
* 获取[分配 CPU 资源给容器和 Pod](/zh-cn/docs/tasks/configure-pod-container/assign-cpu-resource/)
的实践经验
* 阅读 API 参考如何定义[容器](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container)
及其[资源请求](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#resources)。
* 阅读更多关于[本地临时存储](/zh-cn/docs/concepts/storage/ephemeral-storage/)的内容。
Expand Down