Skip to content

Commit dd1e1ae

Browse files
committed
[zh] update concept workload pods
1 parent 15be888 commit dd1e1ae

File tree

6 files changed

+182
-248
lines changed

6 files changed

+182
-248
lines changed

content/zh/docs/concepts/workloads/pods/_index.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -480,21 +480,26 @@ Pod 中的容器所看到的系统主机名与为 Pod 配置的 `name` 属性值
480480
<!--
481481
## Privileged mode for containers
482482
483-
Any container in a Pod can enable privileged mode, using the `privileged` flag on
484-
the [security context](/docs/tasks/configure-pod-container/security-context/) of the container spec. This is useful for containers that want to use operating system administrative capabilities such as manipulating the network stack or accessing hardware devices.
485-
Processes within a privileged container get almost the same privileges that are available to processes outside a container.
483+
In Linux, any container in a Pod can enable privileged mode using the `privileged` (Linux) flag on the [security context](/docs/tasks/configure-pod-container/security-context/) of the container spec. This is useful for containers that want to use operating system administrative capabilities such as manipulating the network stack or accessing hardware devices.
484+
485+
If your cluster has the `WindowsHostProcessContainers` feature enabled, you can create a [Windows HostProcess pod](/docs/tasks/configure-pod-container/create-hostprocess-pod) by setting the `windowsOptions.hostProcess` flag on the security context of the pod spec. All containers in these pods must run as Windows HostProcess containers. HostProcess pods run directly on the host and can also be used to perform administrative tasks as is done with Linux privileged containers.
486486
-->
487487
## 容器的特权模式 {#privileged-mode-for-containers}
488488

489-
Pod 中的任何容器都可以使用容器规约中的
489+
在 Linux 中,Pod 中的任何容器都可以使用容器规约中的
490490
[安全性上下文](/zh/docs/tasks/configure-pod-container/security-context/)中的
491-
`privileged` 参数启用特权模式。
491+
`privileged`(Linux)参数启用特权模式。
492492
这对于想要使用操作系统管理权能(Capabilities,如操纵网络堆栈和访问设备)
493493
的容器很有用。
494-
容器内的进程几乎可以获得与容器外的进程相同的特权。
494+
495+
如果你的集群启用了 `WindowsHostProcessContainers` 特性,你可以使用 Pod 规约中安全上下文的
496+
`windowsOptions.hostProcess` 参数来创建
497+
[Windows HostProcess Pod](/zh/docs/tasks/configure-pod-container/create-hostprocess-pod/)
498+
这些 Pod 中的所有容器都必须以 Windows HostProcess 容器方式运行。
499+
HostProcess Pod 可以直接运行在主机上,它也能像 Linux 特权容器一样,用于执行管理任务。
495500

496501
<!--
497-
Your {< glossary_tooltip text="container runtime" term_id="container-runtime" >}} must support the concept of a privileged container for this setting to be relevant.
502+
Your {{< glossary_tooltip text="container runtime" term_id="container-runtime" >}} must support the concept of a privileged container for this setting to be relevant.
498503
-->
499504
{{< note >}}
500505
你的{{< glossary_tooltip text="容器运行时" term_id="container-runtime" >}}必须支持
@@ -538,29 +543,61 @@ but cannot be controlled from there.
538543
这意味着在节点上运行的 Pod 在 API 服务器上是可见的,但不可以通过 API
539544
服务器来控制。
540545

546+
{{< note >}}
547+
<!--
548+
The `spec` of a static Pod cannot refer to other API objects
549+
(e.g., {{< glossary_tooltip text="ServiceAccount" term_id="service-account" >}},
550+
{{< glossary_tooltip text="ConfigMap" term_id="configmap" >}},
551+
{{< glossary_tooltip text="Secret" term_id="secret" >}}, etc).
552+
-->
553+
静态 Pod 的 `spec` 不能引用其他的 API 对象(例如:{{< glossary_tooltip text="ServiceAccount" term_id="service-account" >}}、{{< glossary_tooltip text="ConfigMap" term_id="configmap" >}}、{{< glossary_tooltip text="Secret" term_id="secret" >}}等)。
554+
{{< /note >}}
555+
556+
<!--
557+
## Container probes
558+
559+
A _probe_ is a diagnostic performed periodically by the kubelet on a container. To perform a diagnostic, the kubelet can invoke different actions:
560+
561+
- `ExecAction` (performed with the help of the container runtime)
562+
- `TCPSocketAction` (checked directly by the kubelet)
563+
- `HTTPGetAction` (checked directly by the kubelet)
564+
565+
You can read more about [probes](/docs/concepts/workloads/pods/pod-lifecycle/#container-probes)
566+
in the Pod Lifecycle documentation.
567+
-->
568+
## 容器探针 {#container-probes}
569+
570+
_Probe_ 是由 kubelet 对容器执行的定期诊断。要执行诊断,kubelet 可以执行三种动作:
571+
572+
- `ExecAction`(借助容器运行时执行)
573+
- `TCPSocketAction`(由 kubelet 直接检测)
574+
- `HTTPGetAction`(由 kubelet 直接检测)
575+
576+
你可以参阅 Pod 的生命周期文档中的[探针](/zh/docs/concepts/workloads/pods/pod-lifecycle/#container-probes)部分。
577+
541578
## {{% heading "whatsnext" %}}
542579

543580
<!--
544581
* Learn about the [lifecycle of a Pod](/docs/concepts/workloads/pods/pod-lifecycle/).
545582
* Learn about [RuntimeClass](/docs/concepts/containers/runtime-class/) and how you can use it to
546583
configure different Pods with different container runtime configurations.
547584
* Read about [Pod topology spread constraints](/docs/concepts/workloads/pods/pod-topology-spread-constraints/).
548-
* Read about [PodDisruptionBudget](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/) and how you can use it to manage application availability during disruptions.
549-
* Pod is a top-level resource in the Kubernetes REST API.
550-
The [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core)
585+
* Read about [PodDisruptionBudget](/docs/concepts/workloads/pods/disruptions/) and how you can use it to manage application availability during disruptions.
586+
* Pod is a top-level resource in the Kubernetes REST API.
587+
The {{< api-reference page="workload-resources/pod-v1" >}}
551588
object definition describes the object in detail.
552-
* [The Distributed System Toolkit: Patterns for Composite Containers](https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns) explains common layouts for Pods with more than one container.
553-
--
589+
* [The Distributed System Toolkit: Patterns for Composite Containers](/blog/2015/06/the-distributed-system-toolkit-patterns/) explains common layouts for Pods with more than one container.
590+
-->
554591
* 了解 [Pod 生命周期](/zh/docs/concepts/workloads/pods/pod-lifecycle/)
555592
* 了解 [RuntimeClass](/zh/docs/concepts/containers/runtime-class/),以及如何使用它
556593
来配置不同的 Pod 使用不同的容器运行时配置
557594
* 了解 [Pod 拓扑分布约束](/zh/docs/concepts/workloads/pods/pod-topology-spread-constraints/)
558595
* 了解 [PodDisruptionBudget](/zh/docs/concepts/workloads/pods/disruptions/),以及你
559-
如何可以利用它在出现干扰因素时管理应用的可用性
560-
* Pod 在 Kubernetes REST API 中是一个顶层资源
561-
[Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core)
596+
如何可以利用它在出现干扰因素时管理应用的可用性
597+
* Pod 在 Kubernetes REST API 中是一个顶层资源
598+
{{< api-reference page="workload-resources/pod-v1" >}}
562599
对象的定义中包含了更多的细节信息。
563-
* 博客 [分布式系统工具箱:复合容器模式](https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns)
600+
* 博客 [分布式系统工具箱:复合容器模式](/blog/2015/06/the-distributed-system-toolkit-patterns/)
564601
中解释了在同一 Pod 中包含多个容器时的几种常见布局。
565602

566603
<!--

content/zh/docs/concepts/workloads/pods/disruptions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ an application. Examples are:
5252
- cloud provider or hypervisor failure makes VM disappear
5353
- a kernel panic
5454
- the node disappears from the cluster due to cluster network partition
55-
- eviction of a pod due to the node being [out-of-resources](/docs/tasks/administer-cluster/out-of-resource/).
55+
- eviction of a pod due to the node being [out-of-resources](/docs/concepts/scheduling-eviction/node-pressure-eviction/).
5656
-->
5757

5858
- 节点下层物理机的硬件故障
5959
- 集群管理员错误地删除虚拟机(实例)
6060
- 云提供商或虚拟机管理程序中的故障导致的虚拟机消失
6161
- 内核错误
6262
- 节点由于集群网络隔离从集群中消失
63-
- 由于节点[资源不足](/zh/docs/tasks/administer-cluster/out-of-resource/)导致 pod 被驱逐。
63+
- 由于节点[资源不足](/zh/docs/concepts/scheduling-eviction/node-pressure-eviction/)导致 pod 被驱逐。
6464

6565
<!--
6666
Except for the out-of-resources condition, all these conditions
@@ -161,7 +161,7 @@ rolling out node software updates can cause voluntary disruptions. Also, some im
161161
of cluster (node) autoscaling may cause voluntary disruptions to defragment and compact nodes.
162162
Your cluster administrator or hosting provider should have documented what level of voluntary
163163
disruptions, if any, to expect. Certain configuration options, such as
164-
[using PriorityClasses](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
164+
[using PriorityClasses](/docs/concepts/scheduling-eviction/pod-priority-preemption/)
165165
in your pod spec can also cause voluntary (and involuntary) disruptions.
166166
-->
167167
自愿干扰的频率各不相同。在一个基本的 Kubernetes 集群中,没有自愿干扰(只有用户触发的干扰)。
@@ -170,7 +170,7 @@ in your pod spec can also cause voluntary (and involuntary) disruptions.
170170
实现可能导致碎片整理和紧缩节点的自愿干扰。集群
171171
管理员或托管提供商应该已经记录了各级别的自愿干扰(如果有的话)。
172172
有些配置选项,例如在 pod spec 中
173-
[使用 PriorityClasses](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
173+
[使用 PriorityClasses](/zh/docs/concepts/scheduling-eviction/pod-priority-preemption/)
174174
也会产生自愿(和非自愿)的干扰。
175175

176176
<!--

content/zh/docs/concepts/workloads/pods/ephemeral-containers.md

Lines changed: 9 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ weight: 80
1212

1313
<!-- overview -->
1414

15-
{{< feature-state state="alpha" for_k8s_version="v1.16" >}}
15+
{{< feature-state state="alpha" for_k8s_version="v1.22" >}}
1616

1717
<!--
1818
This page provides an overview of ephemeral containers: a special type of container
@@ -27,14 +27,12 @@ containers to inspect services rather than to build applications.
2727

2828
{{< warning >}}
2929
<!--
30-
Ephemeral containers are in early alpha state and are not suitable for production
31-
clusters. You should expect the feature not to work in some situations, such as
32-
when targeting the namespaces of a container. In accordance with the [Kubernetes
33-
Deprecation Policy](/docs/reference/using-api/deprecation-policy/), this alpha
34-
feature could change significantly in the future or be removed entirely.
30+
Ephemeral containers are in alpha state and are not suitable for production
31+
clusters. In accordance with the [Kubernetes Deprecation Policy](
32+
/docs/reference/using-api/deprecation-policy/), this alpha feature could change
33+
significantly in the future or be removed entirely.
3534
-->
36-
临时容器处于早期的 Alpha 阶段,不适用于生产环境集群。
37-
应该预料到临时容器在某些情况下不起作用,例如在定位容器的命名空间时。
35+
临时容器处于 Alpha 阶段,不适用于生产环境集群。
3836
根据 [Kubernetes 弃用政策](/zh/docs/reference/using-api/deprecation-policy/)
3937
此 Alpha 功能将来可能发生重大变化或被完全删除。
4038
{{< /warning >}}
@@ -141,151 +139,8 @@ you can view processes in other containers.
141139
[进程名字空间共享](/zh/docs/tasks/configure-pod-container/share-process-namespace/)
142140
很有帮助,可以查看其他容器中的进程。
143141

142+
{{% heading "whatsnext" %}}
144143
<!--
145-
See [Debugging with Ephemeral Debug Container](/docs/tasks/debug-application-cluster/debug-running-pod/#ephemeral-container)
146-
for examples of troubleshooting using ephemeral containers.
144+
* Learn how to [debug pods using ephemeral containers](/docs/tasks/debug-application-cluster/debug-running-pod/#ephemeral-container).
147145
-->
148-
关于如何使用临时容器来执行故障排查的例子,可参阅
149-
[使用临时调试容器来调试](/zh/docs/tasks/debug-application-cluster/debug-running-pod/#ephemeral-container)
150-
151-
<!--
152-
## Ephemeral containers API
153-
-->
154-
### 临时容器 API {#ephemeral-containers-api}
155-
156-
{{< note >}}
157-
<!--
158-
The examples in this section require the `EphemeralContainers` [feature
159-
gate](/docs/reference/command-line-tools-reference/feature-gates/) to be
160-
enabled, and Kubernetes client and server version v1.16 or later.
161-
-->
162-
本节中的示例要求启用 `EphemeralContainers`
163-
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
164-
并且 kubernetes 客户端和服务端版本要求为 v1.16 或更高版本。
165-
{{< /note >}}
166-
167-
<!--
168-
The examples in this section demonstrate how ephemeral containers appear in
169-
the API. You would normally use `kubectl debug` or another `kubectl`
170-
[plugin](/docs/tasks/extend-kubectl/kubectl-plugins/) to automate these steps
171-
rather than invoking the API directly.
172-
-->
173-
本节中的示例演示了临时容器如何出现在 API 中。
174-
通常,你会使用 `kubectl debug` 或别的 `kubectl`
175-
[插件](/zh/docs/tasks/extend-kubectl/kubectl-plugins/) 自动执行这些步骤,而不是直接调用API。
176-
177-
<!--
178-
Ephemeral containers are created using the `ephemeralcontainers` subresource
179-
of Pod, which can be demonstrated using `kubectl -raw`. First describe
180-
the ephemeral container to add as an `EphemeralContainers` list:
181-
-->
182-
临时容器是使用 Pod 的 `ephemeralcontainers` 子资源创建的,可以使用
183-
`kubectl --raw` 命令进行显示。
184-
首先描述临时容器被添加为一个 `EphemeralContainers` 列表:
185-
186-
```json
187-
{
188-
"apiVersion": "v1",
189-
"kind": "EphemeralContainers",
190-
"metadata": {
191-
"name": "example-pod"
192-
},
193-
"ephemeralContainers": [{
194-
"command": [
195-
"sh"
196-
],
197-
"image": "busybox",
198-
"imagePullPolicy": "IfNotPresent",
199-
"name": "debugger",
200-
"stdin": true,
201-
"tty": true,
202-
"terminationMessagePolicy": "File"
203-
}]
204-
}
205-
```
206-
207-
<!--
208-
To update the ephemeral containers of the already running `example-pod`:
209-
-->
210-
使用如下命令更新已运行的临时容器 `example-pod`
211-
212-
```shell
213-
kubectl replace --raw /api/v1/namespaces/default/pods/example-pod/ephemeralcontainers -f ec.json
214-
```
215-
216-
<!--
217-
This will return the new list of ephemeral containers:
218-
-->
219-
这将返回临时容器的新列表:
220-
221-
```json
222-
{
223-
"kind":"EphemeralContainers",
224-
"apiVersion":"v1",
225-
"metadata":{
226-
"name":"example-pod",
227-
"namespace":"default",
228-
"selfLink":"/api/v1/namespaces/default/pods/example-pod/ephemeralcontainers",
229-
"uid":"a14a6d9b-62f2-4119-9d8e-e2ed6bc3a47c",
230-
"resourceVersion":"15886",
231-
"creationTimestamp":"2019-08-29T06:41:42Z"
232-
},
233-
"ephemeralContainers":[
234-
{
235-
"name":"debugger",
236-
"image":"busybox",
237-
"command":[
238-
"sh"
239-
],
240-
"resources":{
241-
242-
},
243-
"terminationMessagePolicy":"File",
244-
"imagePullPolicy":"IfNotPresent",
245-
"stdin":true,
246-
"tty":true
247-
}
248-
]
249-
}
250-
```
251-
252-
<!--
253-
You can view the state of the newly created ephemeral container using `kubectl describe`:
254-
-->
255-
可以使用以下命令查看新创建的临时容器的状态:
256-
257-
```shell
258-
kubectl describe pod example-pod
259-
```
260-
261-
输出为:
262-
263-
```
264-
...
265-
Ephemeral Containers:
266-
debugger:
267-
Container ID: docker://cf81908f149e7e9213d3c3644eda55c72efaff67652a2685c1146f0ce151e80f
268-
Image: busybox
269-
Image ID: docker-pullable://busybox@sha256:9f1003c480699be56815db0f8146ad2e22efea85129b5b5983d0e0fb52d9ab70
270-
Port: <none>
271-
Host Port: <none>
272-
Command:
273-
sh
274-
State: Running
275-
Started: Thu, 29 Aug 2019 06:42:21 +0000
276-
Ready: False
277-
Restart Count: 0
278-
Environment: <none>
279-
Mounts: <none>
280-
...
281-
```
282-
283-
<!--
284-
You can attach to the new ephemeral container using `kubectl attach`:
285-
-->
286-
可以使用以下命令连接到新的临时容器:
287-
288-
```shell
289-
kubectl attach -it example-pod -c debugger
290-
```
291-
146+
* 了解如何[使用临时调试容器来进行调试](/zh/docs/tasks/debug-application-cluster/debug-running-pod/#ephemeral-container)

0 commit comments

Comments
 (0)