Skip to content

Commit

Permalink
sync /working-with-objects/_index.md annotations field-selectors
Browse files Browse the repository at this point in the history
u、

Update _index.md
  • Loading branch information
asa3311 committed Sep 27, 2023
1 parent 5f35e27 commit ed866d2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
41 changes: 27 additions & 14 deletions content/zh-cn/docs/concepts/overview/working-with-objects/_index.md
Expand Up @@ -68,7 +68,7 @@ Kubernetes 系统,你想要的集群工作负载状态看起来应是什么样
这就是 Kubernetes 集群所谓的**期望状态(Desired State)**

<!--
To work with Kubernetes objects--whether to create, modify, or delete them--you'll need to use the
To work with Kubernetes objectswhether to create, modify, or delete themyou'll need to use the
[Kubernetes API](/docs/concepts/overview/kubernetes-api/). When you use the `kubectl` command-line
interface, for example, the CLI makes the necessary Kubernetes API calls for you. You can also use
the Kubernetes API directly in your own programs using one of the
Expand Down Expand Up @@ -139,32 +139,36 @@ For more information on the object spec, status, and metadata, see the
When you create an object in Kubernetes, you must provide the object spec that describes its
desired state, as well as some basic information about the object (such as a name). When you use
the Kubernetes API to create the object (either directly or via `kubectl`), that API request must
include that information as JSON in the request body. **Most often, you provide the information to
`kubectl` in a .yaml file.** `kubectl` converts the information to JSON when making the API
request.
include that information as JSON in the request body.
Most often, you provide the information to `kubectl` in file known as a _manifest_.
By convention, manifests are YAML (you could also use JSON format).
Tools such as `kubectl` convert the information from a manifest into JSON or another supported
serialization format when making the API request over HTTP.
-->
### 描述 Kubernetes 对象 {#describing-a-kubernetes-object}

创建 Kubernetes 对象时,必须提供对象的 `spec`,用来描述该对象的期望状态,
以及关于对象的一些基本信息(例如名称)。
当使用 Kubernetes API 创建对象时(直接创建或经由 `kubectl` 创建),
API 请求必须在请求主体中包含 JSON 格式的信息。
**大多数情况下,你需要提供 `.yaml` 文件为 kubectl 提供这些信息**
`kubectl` 在发起 API 请求时,将这些信息转换成 JSON 格式。

大多数情况下,你会通过 **清单(Manifest)** 文件为 `kubectl` 提供这些信息。
按照惯例,清单是 YAML 格式的(你也可以使用 JSON 格式)。
`kubectl` 这样的工具在通过 HTTP 进行 API 请求时,
会将清单中的信息转换为 JSON 或其他受支持的序列化格式。
<!--
Here's an example `.yaml` file that shows the required fields and object spec for a Kubernetes Deployment:
Here's an example manifest that shows the required fields and object spec for a Kubernetes
Deployment:
-->
这里有一个 `.yaml` 示例文件,展示了 Kubernetes Deployment 的必需字段和对象 `spec`
这里有一个清单示例文件,展示了 Kubernetes Deployment 的必需字段和对象 `spec`

{{< code file="application/deployment.yaml" >}}
{{% code_sample file="application/deployment.yaml" %}}

<!--
One way to create a Deployment using a `.yaml` file like the one above is to use the
One way to create a Deployment using a manifest file like the one above is to use the
[`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply) command
in the `kubectl` command-line interface, passing the `.yaml` file as an argument. Here's an example:
-->
相较于上面使用 `.yaml` 文件来创建 Deployment,另一种类似的方式是使用 `kubectl` 命令行接口(CLI)中的
与上面使用清单文件来创建 Deployment 类似,另一种方式是使用 `kubectl` 命令行接口(CLI)
[`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply) 命令,
`.yaml` 文件作为参数。下面是一个示例:

Expand All @@ -184,7 +188,8 @@ deployment.apps/nginx-deployment created
<!--
### Required fields
In the `.yaml` file for the Kubernetes object you want to create, you'll need to set values for the following fields:
In the manifest (YAML or JSON file) for the Kubernetes object you want to create, you'll need to set values for
the following fields:
* `apiVersion` - Which version of the Kubernetes API you're using to create this object
* `kind` - What kind of object you want to create
Expand All @@ -193,7 +198,7 @@ In the `.yaml` file for the Kubernetes object you want to create, you'll need to
-->
### 必需字段 {#required-fields}

在想要创建的 Kubernetes 对象所对应的 `.yaml` 文件中,需要配置的字段如下:
在想要创建的 Kubernetes 对象所对应的清单(YAML 或 JSON 文件)中,需要配置的字段如下:

* `apiVersion` - 创建该对象所使用的 Kubernetes API 的版本
* `kind` - 想要创建的对象的类别
Expand Down Expand Up @@ -304,6 +309,10 @@ If you're new to Kubernetes, read more about the following:
* [Deployment](/docs/concepts/workloads/controllers/deployment/) objects.
* [Controllers](/docs/concepts/architecture/controller/) in Kubernetes.
* [kubectl](/docs/reference/kubectl/) and [kubectl commands](/docs/reference/generated/kubectl/kubectl-commands).
[Kubernetes Object Management](/docs/concepts/overview/working-with-objects/object-management/)
explains how to use `kubectl` to manage objects.
You might need to [install kubectl](/docs/tasks/tools/#kubectl) if you don't already have it available.
-->
如果你刚开始学习 Kubernetes,可以进一步阅读以下信息:

Expand All @@ -313,6 +322,10 @@ If you're new to Kubernetes, read more about the following:
* [kubectl](/zh-cn/docs/reference/kubectl/)
[kubectl 命令](/docs/reference/generated/kubectl/kubectl-commands)

[Kubernetes 对象管理](/zh-cn/docs/concepts/overview/working-with-objects/object-management/)
介绍了如何使用 `kubectl` 来管理对象。
如果你还没有安装 `kubectl`,你可能需要[安装 kubectl](/zh-cn/docs/tasks/tools/#kubectl)

<!--
To learn about the Kubernetes API in general, visit:
Expand Down
Expand Up @@ -163,6 +163,8 @@ spec:
## {{% heading "whatsnext" %}}

<!--
Learn more about [Labels and Selectors](/docs/concepts/overview/working-with-objects/labels/).
- Learn more about [Labels and Selectors](/docs/concepts/overview/working-with-objects/labels/).
- Find [Well-known labels, Annotations and Taints](/docs/reference/labels-annotations-taints/)
-->
进一步了解[标签和选择算符](/zh-cn/docs/concepts/overview/working-with-objects/labels/)
- 进一步了解[标签和选择算符](/zh-cn/docs/concepts/overview/working-with-objects/labels/)
- 查找[众所周知的标签、注解和污点](/zh-cn/docs/reference/labels-annotations-taints/)
Expand Up @@ -78,6 +78,15 @@ You can use the `=`, `==`, and `!=` operators with field selectors (`=` and `==`
kubectl get services --all-namespaces --field-selector metadata.namespace!=default
```

{{< note >}}
<!--
[Set-based operators](/docs/concepts/overview/working-with-objects/labels/#set-based-requirement)
(`in`, `notin`, `exists`) are not supported for field selectors.
-->
[基于集合的操作符](/zh-cn/docs/concepts/overview/working-with-objects/labels/#set-based-requirement)
`in``notin``exists`)不支持字段选择算符。
{{< /note >}}

<!--
## Chained selectors
Expand Down

0 comments on commit ed866d2

Please sign in to comment.