From 35174abcd93bba9ff04c55923e478e83d35a65c6 Mon Sep 17 00:00:00 2001 From: Sean Wei Date: Wed, 20 Jul 2022 00:26:36 +0800 Subject: [PATCH] [zh-cn] Update replicationcontroller.md --- .../controllers/replicationcontroller.md | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/content/zh-cn/docs/concepts/workloads/controllers/replicationcontroller.md b/content/zh-cn/docs/concepts/workloads/controllers/replicationcontroller.md index 851dafd0a0..0d9f4b7142 100644 --- a/content/zh-cn/docs/concepts/workloads/controllers/replicationcontroller.md +++ b/content/zh-cn/docs/concepts/workloads/controllers/replicationcontroller.md @@ -26,10 +26,10 @@ weight: 90 +{{< note >}} -{{< note >}} 现在推荐使用配置 [`ReplicaSet`](/zh-cn/docs/concepts/workloads/controllers/replicaset/) 的 [`Deployment`](/zh-cn/docs/concepts/workloads/controllers/deployment/) 来建立副本管理机制。 {{< /note >}} @@ -56,7 +56,7 @@ only a single pod. A ReplicationController is similar to a process supervisor, but instead of supervising individual processes on a single node, the ReplicationController supervises multiple pods across multiple nodes. --> -## ReplicationController 如何工作 +## ReplicationController 如何工作 {#how-a-replicationcontroller-works} 当 Pod 数量过多时,ReplicationController 会终止多余的 Pod。当 Pod 数量太少时,ReplicationController 将会启动新的 Pod。 与手动创建的 Pod 不同,由 ReplicationController 创建的 Pod 在失败、被删除或被终止时会被自动替换。 @@ -82,7 +82,7 @@ service, such as web servers. This example ReplicationController config runs three copies of the nginx web server. --> -## 运行一个示例 ReplicationController +## 运行一个示例 ReplicationController {#running-an-example-replicationcontroller} 这个示例 ReplicationController 配置运行 nginx Web 服务器的三个副本。 @@ -187,14 +187,18 @@ specifies an expression with the name from each pod in the returned list. ## Writing a ReplicationController Spec As with all other Kubernetes config, a ReplicationController needs `apiVersion`, `kind`, and `metadata` fields. +The name of a ReplicationController object must be a valid +[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names). For general information about working with configuration files, see [object management](/docs/concepts/overview/working-with-objects/object-management/). A ReplicationController also needs a [`.spec` section](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status). --> -## 编写一个 ReplicationController 规约 +## 编写一个 ReplicationController 规约 {#writing-a-replicationcontroller-spec} 与所有其它 Kubernetes 配置一样,ReplicationController 需要 `apiVersion`、 `kind` 和 `metadata` 字段。 +ReplicationController 对象的名称必须是有效的 +[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)。 有关使用配置文件的常规信息,参考 [对象管理](/zh-cn/docs/concepts/overview/working-with-objects/object-management/)。 @@ -205,14 +209,14 @@ ReplicationController 也需要一个 [`.spec` 部分](https://git.k8s.io/commun The `.spec.template` is the only required field of the `.spec`. -The `.spec.template` is a [pod template](/docs/concepts/workloads/pods/pod-overview/#pod-templates). It has exactly the same schema as a [pod](/docs/concepts/workloads/pods/pod/), except it is nested and does not have an `apiVersion` or `kind`. +The `.spec.template` is a [pod template](/docs/concepts/workloads/pods/#pod-templates). It has exactly the same schema as a {{< glossary_tooltip text="Pod" term_id="pod" >}}, except it is nested and does not have an `apiVersion` or `kind`. --> ### Pod 模板 {#pod-template} `.spec.template` 是 `.spec` 的唯一必需字段。 `.spec.template` 是一个 [Pod 模板](/zh-cn/docs/concepts/workloads/pods/#pod-templates)。 -它的模式与 [Pod](/zh-cn/docs/concepts/workloads/pods/) 完全相同,只是它是嵌套的,没有 `apiVersion` 或 `kind` 属性。 +它的模式与 {{< glossary_tooltip text="Pod" term_id="pod" >}} 完全相同,只是它是嵌套的,没有 `apiVersion` 或 `kind` 属性。 除了 Pod 所需的字段外,ReplicationController 中的 Pod 模板必须指定适当的标签和适当的重新启动策略。 对于标签,请确保不与其他控制器重叠。参考 [Pod 选择算符](#pod-selector)。 @@ -368,7 +372,7 @@ Pods may be removed from a ReplicationController's target set by changing their -## 常见的使用模式 +## 常见的使用模式 {#common-usage-patterns} ### 滚动更新 {#rolling-updates} @@ -407,17 +411,11 @@ ReplicationController 的设计目的是通过逐个替换 Pod 以方便滚动 Ideally, the rolling update controller would take application readiness into account, and would ensure that a sufficient number of pods were productively serving at any given time. The two ReplicationControllers would need to create pods with at least one differentiating label, such as the image tag of the primary container of the pod, since it is typically image updates that motivate rolling updates. - -Rolling update is implemented in the client tool -[`kubectl rolling-update`](/docs/reference/generated/kubectl/kubectl-commands#rolling-update). Visit [`kubectl rolling-update` task](/docs/tasks/run-application/rolling-update-replication-controller/) for more concrete examples. --> 理想情况下,滚动更新控制器将考虑应用程序的就绪情况,并确保在任何给定时间都有足够数量的 Pod 有效地提供服务。 这两个 ReplicationController 将需要创建至少具有一个不同标签的 Pod,比如 Pod 主要容器的镜像标签,因为通常是镜像更新触发滚动更新。 -滚动更新是在客户端工具 [`kubectl rolling-update`](/docs/reference/generated/kubectl/kubectl-commands#rolling-update) -中实现的。访问 [`kubectl rolling-update` 任务](/zh-cn/docs/tasks/run-application/rolling-update-replication-controller/)以获得更多的具体示例。 - -## 编写多副本的应用 +## 编写多副本的应用 {#writing-programs-for-replication} 由 ReplicationController 创建的 Pod 是可替换的,语义上是相同的, 尽管随着时间的推移,它们的配置可能会变得异构。 @@ -477,9 +475,9 @@ Pods created by a ReplicationController are intended to be fungible and semantic -## ReplicationController 的职责 +## ReplicationController 的职责 {#responsibilities-of-the-replicationcontroller} ReplicationController 仅确保所需的 Pod 数量与其标签选择算符匹配,并且是可操作的。 目前,它的计数中只排除终止的 Pod。 @@ -488,7 +486,7 @@ ReplicationController 仅确保所需的 Pod 数量与其标签选择算符匹 我们计划发出事件,这些事件可以被外部客户端用来实现任意复杂的替换和/或缩减策略。 ReplicationController 永远被限制在这个狭隘的职责范围内。 它本身既不执行就绪态探测,也不执行活跃性探测。 @@ -501,7 +499,7 @@ ReplicationController 永远被限制在这个狭隘的职责范围内。 我们甚至计划考虑批量创建 Pod 的机制(查阅 [#170](https://issue.k8s.io/170))。 ReplicationController 旨在成为可组合的构建基元。 我们希望在它和其他补充原语的基础上构建更高级别的 API 或者工具,以便于将来的用户使用。 @@ -516,7 +514,7 @@ Replication controller is a top-level resource in the Kubernetes REST API. More API object can be found at: [ReplicationController API object](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#replicationcontroller-v1-core). --> -## API 对象 +## API 对象 {#api-object} 在 Kubernetes REST API 中 Replication controller 是顶级资源。 更多关于 API 对象的详细信息可以在 @@ -524,13 +522,14 @@ API object can be found at: -## ReplicationController 的替代方案 +## ReplicationController 的替代方案 {#alternatives-to-replicationcontroller} ### ReplicaSet @@ -569,7 +568,7 @@ ReplicationController 将本地容器重启委托给节点上的某个代理(例 ### Job