Skip to content

Commit 9f82eb3

Browse files
committed
[zh-cn]sync field-selectors.md
Signed-off-by: xin.li <xin.li@daocloud.io>
1 parent c0557b4 commit 9f82eb3

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

‎content/zh-cn/docs/concepts/overview/working-with-objects/field-selectors.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 字段选择器
2+
title: 字段选择算符
33
content_type: concept
44
weight: 70
55
---
@@ -15,9 +15,9 @@ _Field selectors_ let you [select Kubernetes resources](/docs/concepts/overview/
1515
_Field selectors_ let you select Kubernetes {{< glossary_tooltip text="objects" term_id="object" >}} based on the
1616
value of one or more resource fields. Here are some examples of field selector queries:
1717
-->
18-
字段选择器(Field selectors)”允许你根据一个或多个资源字段的值筛选
18+
字段选择算符(Field selectors)”允许你根据一个或多个资源字段的值筛选
1919
Kubernetes {{< glossary_tooltip text="对象" term_id="object" >}}。
20-
下面是一些使用字段选择器查询的例子
20+
下面是一些使用字段选择算符查询的例子
2121

2222
* `metadata.name=my-service`
2323
* `metadata.namespace!=default`
@@ -38,7 +38,7 @@ kubectl get pods --field-selector status.phase=Running
3838
<!--
3939
Field selectors are essentially resource *filters*. By default, no selectors/filters are applied, meaning that all resources of the specified type are selected. This makes the `kubectl` queries `kubectl get pods` and `kubectl get pods --field-selector ""` equivalent.
4040
-->
41-
字段选择器本质上是资源“过滤器(Filters)”。默认情况下,字段选择器/过滤器是未被应用的,
41+
字段选择算符本质上是资源“过滤器(Filters)”。默认情况下,字段选择算符/过滤器是未被应用的,
4242
这意味着指定类型的所有资源都会被筛选出来。
4343
这使得 `kubectl get pods``kubectl get pods --field-selector ""`
4444
这两个 `kubectl` 查询是等价的。
@@ -52,9 +52,9 @@ Supported field selectors vary by Kubernetes resource type. All resource types s
5252
-->
5353
## 支持的字段 {#supported-fields}
5454

55-
不同的 Kubernetes 资源类型支持不同的字段选择器
55+
不同的 Kubernetes 资源类型支持不同的字段选择算符
5656
所有资源类型都支持 `metadata.name``metadata.namespace` 字段。
57-
使用不被支持的字段选择器会产生错误。例如:
57+
使用不被支持的字段选择算符会产生错误。例如:
5858

5959
```shell
6060
kubectl get ingress --field-selector foo.bar=baz
@@ -83,14 +83,32 @@ Error from server (BadRequest): Unable to find "ingresses" that match label sele
8383
| Node | `spec.unschedulable` |
8484
| CertificateSigningRequest | `spec.signerName` |
8585

86+
<!--
87+
### Custom resources fields
88+
89+
All custom resource types support the `metadata.name` and `metadata.namespace` fields.
90+
91+
Additionally, the `spec.versions[*].selectableFields` field of a {{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}}
92+
declares which other fields in a custom resource may be used in field selectors. See [selectable fields for custom resources](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#crd-selectable-fields)
93+
for more information about how to use field selectors with CustomResourceDefinitions.
94+
-->
95+
### 自定义资源字段
96+
97+
所有自定义资源类型都支持 `metadata.name``metadata.namespace` 字段。
98+
99+
此外,{{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}}
100+
`spec.versions[*].selectableFields` 字段声明了自定义资源中哪些其他字段可以用于字段选择算符。
101+
有关如何使用 CustomResourceDefinitions 的字段选择算符的更多信息,
102+
请参阅[自定义资源的选择字段](/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#crd-selectable-fields)
103+
86104
<!--
87105
## Supported operators
88106
89107
You can use the `=`, `==`, and `!=` operators with field selectors (`=` and `==` mean the same thing). This `kubectl` command, for example, selects all Kubernetes Services that aren't in the `default` namespace:
90108
-->
91109
## 支持的操作符 {#supported-operators}
92110

93-
你可在字段选择器中使用 `=``==``!=``=``==` 的意义是相同的)操作符。
111+
你可在字段选择算符中使用 `=``==``!=``=``==` 的意义是相同的)操作符。
94112
例如,下面这个 `kubectl` 命令将筛选所有不属于 `default` 命名空间的 Kubernetes 服务:
95113

96114
```shell
@@ -111,10 +129,10 @@ kubectl get services --all-namespaces --field-selector metadata.namespace!=defa
111129
112130
As with [label](/docs/concepts/overview/working-with-objects/labels) and other selectors, field selectors can be chained together as a comma-separated list. This `kubectl` command selects all Pods for which the `status.phase` does not equal `Running` and the `spec.restartPolicy` field equals `Always`:
113131
-->
114-
## 链式选择器 {#chained-selectors}
132+
## 链式选择算符 {#chained-selectors}
115133

116-
[标签](/zh-cn/docs/concepts/overview/working-with-objects/labels/)和其他选择器一��
117-
字段选择器可以通过使用逗号分隔的列表组成一个选择链
134+
[标签](/zh-cn/docs/concepts/overview/working-with-objects/labels/)和其他选择算符一样
135+
字段选择算符可以通过使用逗号分隔的列表组成一个选择链
118136
下面这个 `kubectl` 命令将筛选 `status.phase` 字段不等于 `Running` 同时
119137
`spec.restartPolicy` 字段等于 `Always` 的所有 Pod:
120138

@@ -129,7 +147,7 @@ You can use field selectors across multiple resource types. This `kubectl` comma
129147
-->
130148
## 多种资源类型 {#multiple-resource-types}
131149

132-
你能够跨多种资源类型来使用字段选择器
150+
你能够跨多种资源类型来使用字段选择算符
133151
下面这个 `kubectl` 命令将筛选出所有不在 `default` 命名空间中的 StatefulSet 和 Service:
134152

135153
```shell

0 commit comments

Comments
 (0)
close