[zh-cn] updated /overview/working-with-objects/kubernetes-objects.md

pull/35469/head
Michael 2022-07-28 14:03:13 +08:00
parent ad25aba971
commit 9163cfc19c
1 changed files with 12 additions and 11 deletions

View File

@ -36,13 +36,13 @@ entities to represent the state of your cluster. Specifically, they can describe
--> -->
## 理解 Kubernetes 对象 {#kubernetes-objects} ## 理解 Kubernetes 对象 {#kubernetes-objects}
在 Kubernetes 系统中,**Kubernetes 对象**是持久化的实体。 在 Kubernetes 系统中,**Kubernetes 对象** 是持久化的实体。
Kubernetes 使用这些实体去表示整个集群的状态。 Kubernetes 使用这些实体去表示整个集群的状态。
特别地是,它们描述了如下信息: 特别地是,它们描述了如下信息:
* 哪些容器化应用正在运行(以及在哪些节点上运行) * 哪些容器化应用正在运行(以及在哪些节点上运行)
* 可以被应用使用的资源 * 可以被应用使用的资源
* 关于应用运行时表现的策略,比如重启策略、升级策略以及容错策略 * 关于应用运行时表现的策略,比如重启策略、升级策略以及容错策略
<!-- <!--
A Kubernetes object is a "record of intent" - once you create the object, A Kubernetes object is a "record of intent" - once you create the object,
@ -57,11 +57,11 @@ the CLI makes the necessary Kubernetes API calls for you.
You can also use the Kubernetes API directly in your own programs using You can also use the Kubernetes API directly in your own programs using
one of the [Client Libraries](/docs/reference/using-api/client-libraries/). one of the [Client Libraries](/docs/reference/using-api/client-libraries/).
--> -->
Kubernetes 对象是“目标性记录”——一旦创建对象Kubernetes 系统将不断工作以确保对象存在。 Kubernetes 对象是“目标性记录” —— 一旦创建对象Kubernetes 系统将不断工作以确保对象存在。
通过创建对象,你就是在告知 Kubernetes 系统,你想要的集群工作负载状态看起来应是什么样子的, 通过创建对象,你就是在告知 Kubernetes 系统,你想要的集群工作负载状态看起来应是什么样子的,
这就是 Kubernetes 集群所谓的 **期望状态Desired State**。 这就是 Kubernetes 集群所谓的 **期望状态Desired State**。
操作 Kubernetes 对象 —— 无论是创建、修改或者删除 —— 需要使用 操作 Kubernetes 对象 —— 无论是创建、修改或者删除 —— 需要使用
[Kubernetes API](/zh-cn/docs/concepts/overview/kubernetes-api)。 [Kubernetes API](/zh-cn/docs/concepts/overview/kubernetes-api)。
比如,当使用 `kubectl` 命令行接口CLICLI 会调用必要的 Kubernetes API 比如,当使用 `kubectl` 命令行接口CLICLI 会调用必要的 Kubernetes API
也可以在程序中使用[客户端库](/zh-cn/docs/reference/using-api/client-libraries/) 也可以在程序中使用[客户端库](/zh-cn/docs/reference/using-api/client-libraries/)
@ -109,8 +109,8 @@ a replacement instance.
当创建 Deployment 时,可能会去设置 Deployment 的 `spec`,以指定该应用要有 3 个副本运行。 当创建 Deployment 时,可能会去设置 Deployment 的 `spec`,以指定该应用要有 3 个副本运行。
Kubernetes 系统读取 Deployment 的 `spec` Kubernetes 系统读取 Deployment 的 `spec`
并启动我们所期望的应用的 3 个实例 —— 更新状态以与规约相匹配。 并启动我们所期望的应用的 3 个实例 —— 更新状态以与规约相匹配。
如果这些实例中有的失败了一种状态变更Kubernetes 系统会通过执行修正操作 如果这些实例中有的失败了一种状态变更Kubernetes 系统会通过执行修正操作来响应
来响应 `spec` 和状态间的不一致 —— 意味着它会启动一个新的实例来替换。 `spec` 和状态间的不一致 —— 意味着它会启动一个新的实例来替换。
<!-- <!--
For more information on the object spec, status, and metadata, see the For more information on the object spec, status, and metadata, see the
@ -183,7 +183,7 @@ In the `.yaml` file for the Kubernetes object you want to create, you'll need to
* `apiVersion` - 创建该对象所使用的 Kubernetes API 的版本 * `apiVersion` - 创建该对象所使用的 Kubernetes API 的版本
* `kind` - 想要创建的对象的类别 * `kind` - 想要创建的对象的类别
* `metadata` - 帮助唯一标识对象的一些数据,包括一个 `name` 字符串、`UID` 和可选的 `namespace` * `metadata` - 帮助唯一标识对象的一些数据,包括一个 `name` 字符串、`UID` 和可选的 `namespace`
* `spec` - 你所期望的该对象的状态 * `spec` - 你所期望的该对象的状态
<!-- <!--
@ -211,12 +211,13 @@ Different kinds of object can also have different `.status`; again, the API refe
detail the structure of that `.status` field, and its content for each different type of object. detail the structure of that `.status` field, and its content for each different type of object.
--> -->
例如,参阅 Pod API 参考文档中 例如,参阅 Pod API 参考文档中
[`spec` 字段](/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec)。 [`spec` 字段](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec)。
对于每个 Pod`.spec` 字段设置了 Pod 及其期望状态(例如 Pod 中每个容器的容器镜像名称)。 对于每个 Pod`.spec` 字段设置了 Pod 及其期望状态(例如 Pod 中每个容器的容器镜像名称)。
另一个对象规约的例子是 StatefulSet API 中的 另一个对象规约的例子是 StatefulSet API 中的
[`spec` 字段](/docs/reference/kubernetes-api/workload-resources/stateful-set-v1/#StatefulSetSpec)。 [`spec` 字段](/zh-cn/docs/reference/kubernetes-api/workload-resources/stateful-set-v1/#StatefulSetSpec)。
对于 StatefulSet 而言,其 `.spec` 字段设置了 StatefulSet 及其期望状态。 对于 StatefulSet 而言,其 `.spec` 字段设置了 StatefulSet 及其期望状态。
在 StatefulSet 的 `.spec` 内,有一个为 Pod 对象提供的[模板](/zh-cn/docs/concepts/workloads/pods/#pod-templates)。该模板描述了 StatefulSet 控制器为了满足 StatefulSet 规约而要创建的 Pod。 在 StatefulSet 的 `.spec` 内,有一个为 Pod 对象提供的[模板](/zh-cn/docs/concepts/workloads/pods/#pod-templates)。
该模板描述了 StatefulSet 控制器为了满足 StatefulSet 规约而要创建的 Pod。
不同类型的对象可以由不同的 `.status` 信息。API 参考页面给出了 `.status` 字段的详细结构, 不同类型的对象可以由不同的 `.status` 信息。API 参考页面给出了 `.status` 字段的详细结构,
以及针对不同类型 API 对象的具体内容。 以及针对不同类型 API 对象的具体内容。