Skip to content

Commit 5dd4b2f

Browse files
committed
[zh-cn]sync pods/_index.md
Signed-off-by: xin.li <[email protected]>
1 parent b6959e0 commit 5dd4b2f

File tree

1 file changed

+130
-90
lines changed
  • content/zh-cn/docs/concepts/workloads/pods

1 file changed

+130
-90
lines changed

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

Lines changed: 130 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ Pod 所建模的是特定于应用的 “逻辑主机”,其中包含一个或
3939

4040
<!--
4141
As well as application containers, a Pod can contain
42-
[init containers](/docs/concepts/workloads/pods/init-containers/) that run
42+
{{< glossary_tooltip text="init containers" term_id="init-container" >}} that run
4343
during Pod startup. You can also inject
44-
[ephemeral containers](/docs/concepts/workloads/pods/ephemeral-containers/)
45-
for debugging if your cluster offers this.
44+
{{< glossary_tooltip text="ephemeral containers" term_id="ephemeral-container" >}}
45+
for debugging a running Pod.
4646
-->
4747
除了应用容器,Pod 还可以包含在 Pod 启动期间运行的
48-
[Init 容器](/zh-cn/docs/concepts/workloads/pods/init-containers/)
49-
你也可以在集群支持[临时性容器](/zh-cn/docs/concepts/workloads/pods/ephemeral-containers/)的情况下,
50-
为调试的目的注入临时性容器。
48+
{{< glossary_tooltip text="Init 容器" term_id="init-container" >}}。
49+
你也可以注入{{< glossary_tooltip text="临时性容器" term_id="ephemeral-container" >}}来调试正在运行的 Pod。
5150

5251
<!-- body -->
5352

@@ -78,6 +77,42 @@ Pod 的共享上下文包括一组 Linux 名字空间、控制组(cgroup)和
7877

7978
Pod 类似于共享名字空间并共享文件系统卷的一组容器。
8079

80+
<!--
81+
Pods in a Kubernetes cluster are used in two main ways:
82+
83+
* **Pods that run a single container**. The "one-container-per-Pod" model is the
84+
most common Kubernetes use case; in this case, you can think of a Pod as a
85+
wrapper around a single container; Kubernetes manages Pods rather than managing
86+
the containers directly.
87+
* **Pods that run multiple containers that need to work together**. A Pod can
88+
encapsulate an application composed of
89+
[multiple co-located containers](#how-pods-manage-multiple-containers) that are
90+
tightly coupled and need to share resources. These co-located containers
91+
form a single cohesive unit.
92+
-->
93+
Kubernetes 集群中的 Pod 主要有两种用法:
94+
95+
* **运行单个容器的 Pod**。"每个 Pod 一个容器"模型是最常见的 Kubernetes 用例;
96+
在这种情况下,可以将 Pod 看作单个容器的包装器,并且 Kubernetes 直接管理 Pod,而不是容器。
97+
* **运行多个协同工作的容器的 Pod**
98+
Pod 可以封装由紧密耦合且需要共享资源的[多个并置容器](#how-pods-manage-multiple-containers)组成的应用。
99+
这些位于同一位置的容器构成一个内聚单元。
100+
101+
<!--
102+
Grouping multiple co-located and co-managed containers in a single Pod is a
103+
relatively advanced use case. You should use this pattern only in specific
104+
instances in which your containers are tightly coupled.
105+
106+
You don't need to run multiple containers to provide replication (for resilience
107+
or capacity); if you need multiple replicas, see
108+
[Workload management](/docs/concepts/workloads/controllers/).
109+
-->
110+
将多个并置、同管的容器组织到一个 Pod 中是一种相对高级的使用场景。
111+
只有在一些场景中,容器之间紧密关联时你才应该使用这种模式。
112+
113+
你不需要运行多个容器来扩展副本(为了弹性或容量);
114+
如果你需要多个副本,请参阅[工作负载管理](/zh-cn/docs/concepts/workloads/controllers/)
115+
81116
<!--
82117
## Using Pods
83118
@@ -116,49 +151,13 @@ create them using workload resources such as {{< glossary_tooltip text="Deployme
116151
term_id="deployment" >}} or {{< glossary_tooltip text="Job" term_id="job" >}}.
117152
If your Pods need to track state, consider the
118153
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}} resource.
119-
120-
Pods in a Kubernetes cluster are used in two main ways:
121154
-->
122155
通常你不需要直接创建 Pod,甚至单实例 Pod。相反,你会使用诸如
123156
{{< glossary_tooltip text="Deployment" term_id="deployment" >}} 或
124157
{{< glossary_tooltip text="Job" term_id="job" >}} 这类工作负载资源来创建 Pod。
125158
如果 Pod 需要跟踪状态,可以考虑
126159
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}} 资源。
127160

128-
Kubernetes 集群中的 Pod 主要有两种用法:
129-
130-
<!--
131-
* **Pods that run a single container**. The "one-container-per-Pod" model is the
132-
most common Kubernetes use case; in this case, you can think of a Pod as a
133-
wrapper around a single container; Kubernetes manages Pods rather than managing
134-
the containers directly.
135-
* **Pods that run multiple containers that need to work together**. A Pod can
136-
encapsulate an application composed of multiple co-located containers that are
137-
tightly coupled and need to share resources. These co-located containers
138-
form a single cohesive unit of service—for example, one container serving data
139-
stored in a shared volume to the public, while a separate _sidecar_ container
140-
refreshes or updates those files.
141-
The Pod wraps these containers, storage resources, and an ephemeral network
142-
identity together as a single unit.
143-
-->
144-
* **运行单个容器的 Pod**。"每个 Pod 一个容器" 模型是最常见的 Kubernetes 用例;
145-
在这种情况下,可以将 Pod 看作单个容器的包装器,并且 Kubernetes 直接管理 Pod,而不是容器。
146-
* **运行多个协同工作的容器的 Pod**
147-
Pod 可能封装由多个紧密耦合且需要共享资源的共处容器组成的应用程序。
148-
这些位于同一位置的容器可能形成单个内聚的服务单元 —— 一个容器将文件从共享卷提供给公众,
149-
而另一个单独的 “边车”(sidecar)容器则刷新或更新这些文件。
150-
Pod 将这些容器和存储资源打包为一个可管理的实体。
151-
152-
{{< note >}}
153-
<!--
154-
Grouping multiple co-located and co-managed containers in a single Pod is a
155-
relatively advanced use case. You should use this pattern only in specific
156-
instances in which your containers are tightly coupled.
157-
-->
158-
将多个并置、同管的容器组织到一个 Pod 中是一种相对高级的使用场景。
159-
只有在一些场景中,容器之间紧密关联时你才应该使用这种模式。
160-
{{< /note >}}
161-
162161
<!--
163162
Each Pod is meant to run a single instance of a given application. If you want to
164163
scale your application horizontally (to provide more overall resources by running
@@ -179,54 +178,6 @@ scaling and auto-healing.
179178
参见 [Pod 和控制器](#pods-and-controllers)以了解 Kubernetes
180179
如何使用工作负载资源及其控制器以实现应用的扩缩和自动修复。
181180

182-
<!--
183-
### How Pods manage multiple containers
184-
185-
Pods are designed to support multiple cooperating processes (as containers) that form
186-
a cohesive unit of service. The containers in a Pod are automatically co-located and
187-
co-scheduled on the same physical or virtual machine in the cluster. The containers
188-
can share resources and dependencies, communicate with one another, and coordinate
189-
when and how they are terminated.
190-
-->
191-
### Pod 怎样管理多个容器 {#how-pods-manage-multiple-containers}
192-
193-
Pod 被设计成支持形成内聚服务单元的多个协作过程(形式为容器)。
194-
Pod 中的容器被自动安排到集群中的同一物理机或虚拟机上,并可以一起进行调度。
195-
容器之间可以共享资源和依赖、彼此通信、协调何时以及何种方式终止自身。
196-
197-
<!--
198-
For example, you might have a container that
199-
acts as a web server for files in a shared volume, and a separate "sidecar" container
200-
that updates those files from a remote source, as in the following diagram:
201-
-->
202-
例如,你可能有一个容器,为共享卷中的文件提供 Web 服务器支持,以及一个单独的
203-
"边车 (sidercar)" 容器负责从远端更新这些文件,如下图所示:
204-
205-
{{< figure src="/zh-cn/docs/images/pod.svg" alt="Pod 创建示意图" class="diagram-medium" >}}
206-
207-
<!--
208-
Some Pods have {{< glossary_tooltip text="init containers" term_id="init-container" >}}
209-
as well as {{< glossary_tooltip text="app containers" term_id="app-container" >}}.
210-
Init containers run and complete before the app containers are started.
211-
-->
212-
有些 Pod 具有 {{< glossary_tooltip text="Init 容器" term_id="init-container" >}}和
213-
{{< glossary_tooltip text="应用容器" term_id="app-container" >}}。
214-
Init 容器会在启动应用容器之前运行并完成。
215-
216-
{{< feature-state for_k8s_version="v1.29" state="beta" >}}
217-
218-
<!--
219-
Enabled by default, the `SidecarContainers` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
220-
allows you to specify `restartPolicy: Always` for init containers.
221-
Setting the `Always` restart policy ensures that the init containers where you set it are
222-
kept running during the entire lifetime of the Pod.
223-
See [Sidecar containers and restartPolicy](/docs/concepts/workloads/pods/init-containers/#sidecar-containers-and-restartpolicy)
224-
for more details.
225-
-->
226-
启用 `SidecarContainers` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)(默认启用)允许你为
227-
Init 容器指定 `restartPolicy: Always`。设置重启策略为 `Always` 会确保 Init 容器在 Pod 的整个生命周期内保持运行。
228-
更多细节参阅[边车容器和重启策略](/zh-cn/docs/concepts/workloads/pods/init-containers/#sidecar-containers-and-restartpolicy)
229-
230181
<!--
231182
Pods natively provide two kinds of shared resources for their constituent containers:
232183
[networking](#pod-networking) and [storage](#pod-storage).
@@ -650,6 +601,95 @@ The `spec` of a static Pod cannot refer to other API objects
650601
{{< glossary_tooltip text="Secret" term_id="secret" >}} 等)。
651602
{{< /note >}}
652603

604+
<!--
605+
### Pods manage multiple containers {#how-pods-manage-multiple-containers}
606+
607+
Pods are designed to support multiple cooperating processes (as containers) that form
608+
a cohesive unit of service. The containers in a Pod are automatically co-located and
609+
co-scheduled on the same physical or virtual machine in the cluster. The containers
610+
can share resources and dependencies, communicate with one another, and coordinate
611+
when and how they are terminated.
612+
-->
613+
### Pod 管理多个容器 {#how-pods-manage-multiple-containers}
614+
615+
Pod 被设计成支持构造内聚的服务单元的多个协作进程(形式为容器)。
616+
Pod 中的容器被自动并置到集群中的同一物理机或虚拟机上,并可以一起进行调度。
617+
容器之间可以共享资源和依赖、彼此通信、协调何时以及何种方式终止自身。
618+
619+
<!--intentionally repeats some text from earlier in the page, with more detail -->
620+
621+
<!--
622+
Pods in a Kubernetes cluster are used in two main ways:
623+
624+
* **Pods that run a single container**. The "one-container-per-Pod" model is the
625+
most common Kubernetes use case; in this case, you can think of a Pod as a
626+
wrapper around a single container; Kubernetes manages Pods rather than managing
627+
the containers directly.
628+
* **Pods that run multiple containers that need to work together**. A Pod can
629+
encapsulate an application composed of
630+
multiple co-located containers that are
631+
tightly coupled and need to share resources. These co-located containers
632+
form a single cohesive unit of service—for example, one container serving data
633+
stored in a shared volume to the public, while a separate
634+
{{< glossary_tooltip text="sidecar container" term_id="sidecar-container" >}}
635+
refreshes or updates those files.
636+
The Pod wraps these containers, storage resources, and an ephemeral network
637+
identity together as a single unit.
638+
-->
639+
Kubernetes 集群中的 Pod 主要有两种用法:
640+
641+
* **运行单个容器的 Pod**。"每个 Pod 一个容器" 模型是最常见的 Kubernetes 用例;
642+
在这种情况下,可以将 Pod 看作单个容器的包装器。Kubernetes 直接管理 Pod,而不是容器。
643+
* **运行多个需要协同工作的容器的 Pod**
644+
Pod 可以封装由多个紧密耦合且需要共享资源的并置容器组成的应用。
645+
这些位于同一位置的容器可能形成单个内聚的服务单元 —— 一个容器将文件从共享卷提供给公众,
646+
而另一个单独的{{< glossary_tooltip text="边车容器" term_id="sidecar-container" >}}则刷新或更新这些文件。
647+
Pod 将这些容器和存储资源打包为一个可管理的实体。
648+
649+
<!--
650+
For example, you might have a container that
651+
acts as a web server for files in a shared volume, and a separate
652+
[sidecar container](/docs/concepts/workloads/pods/sidecar-containers/)
653+
that updates those files from a remote source, as in the following diagram:
654+
-->
655+
例如,你可能有一个容器,为共享卷中的文件提供 Web 服务器支持,以及一个单独的
656+
[边车(Sidercar)](/zh-cn/docs/concepts/workloads/pods/sidecar-containers/)
657+
容器负责从远端更新这些文件,如下图所示:
658+
659+
{{< figure src="/zh-cn/docs/images/pod.svg" alt="Pod 创建示意图" class="diagram-medium" >}}
660+
661+
<!--
662+
Some Pods have {{< glossary_tooltip text="init containers" term_id="init-container" >}}
663+
as well as {{< glossary_tooltip text="app containers" term_id="app-container" >}}.
664+
By default, init containers run and complete before the app containers are started.
665+
-->
666+
有些 Pod 具有 {{< glossary_tooltip text="Init 容器" term_id="init-container" >}}和
667+
{{< glossary_tooltip text="应用容器" term_id="app-container" >}}。
668+
Init 容器默认会在启动应用容器之前运行并完成。
669+
670+
<!--
671+
You can also have [sidecar containers](/docs/concepts/workloads/pods/sidecar-containers/)
672+
that provide auxiliary services to the main application Pod (for example: a service mesh).
673+
-->
674+
你还可以拥有为主应用 Pod 提供辅助服务的
675+
[边车容器](/zh-cn/docs/concepts/workloads/pods/sidecar-containers/)(例如:服务网格)。
676+
677+
678+
{{< feature-state for_k8s_version="v1.29" state="beta" >}}
679+
680+
<!--
681+
Enabled by default, the `SidecarContainers` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
682+
allows you to specify `restartPolicy: Always` for init containers.
683+
Setting the `Always` restart policy ensures that the init containers where you set it are
684+
treated as _sidecars_ that are kept running during the entire lifetime of the Pod.
685+
See [Sidecar containers and restartPolicy](/docs/concepts/workloads/pods/init-containers/#sidecar-containers-and-restartpolicy)
686+
for more details.
687+
-->
688+
启用 `SidecarContainers` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)(默认启用)允许你为
689+
Init 容器指定 `restartPolicy: Always`。设置重启策略为 `Always` 会确保设置的 Init 容器被视为**边车**
690+
并在 Pod 的整个生命周期内保持运行。
691+
更多细节参阅[边车容器和重启策略](/zh-cn/docs/concepts/workloads/pods/init-containers/#sidecar-containers-and-restartpolicy)
692+
653693
<!--
654694
## Container probes
655695

0 commit comments

Comments
 (0)