@@ -80,8 +80,8 @@ as a permission check
80
80
(used to trigger
81
81
[API-initiated eviction](/docs/concepts/scheduling-eviction/api-eviction/)).
82
82
-->
83
- 大多数 Kubernetes API 资源类型都是
84
- [ 对象] ( /zh-cn/docs/concepts/overview/working-with-objects/kubernetes-objects/#kubernetes-objects ) :
83
+ 大多数 Kubernetes API
84
+ 资源类型都是 [ 对象] ( /zh-cn/docs/concepts/overview/working-with-objects/kubernetes-objects/#kubernetes-objects ) :
85
85
它们代表集群上某个概念的具体实例,例如 Pod 或命名空间。
86
86
少数 API 资源类型是 “虚拟的”,它们通常代表的是操作而非对象本身,
87
87
例如权限检查(使用带有 JSON 编码的 ` SubjectAccessReview ` 主体的 POST 到 ` subjectaccessreviews ` 资源),
@@ -163,13 +163,13 @@ The following paths are used to retrieve collections and resources:
163
163
* `GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME` - return the instance of the resource type with NAME in NAMESPACE
164
164
-->
165
165
## 资源 URI {#resource-uris}
166
- 所有资源类型要么是集群作用域的(` /apis/GROUP/VERSION/* ` ),要么是名字空间
167
- 作用域的(` /apis/GROUP/VERSION/namespaces/NAMESPACE/* ` )。
168
- 名字空间作用域的资源类型会在其名字空间被删除时也被删除,并且对该资源类型的
169
- 访问是由定义在名字空间域中的授权检查来控制的。
170
166
171
- 你还可以访问资源集合(例如:列出所有 Node)。以下路径用于检索集合和资源:
167
+ 所有资源类型要么是集群作用域的(` /apis/GROUP/VERSION/* ` ),
168
+ 要么是名字空间作用域的(` /apis/GROUP/VERSION/namespaces/NAMESPACE/* ` )。
169
+ 名字空间作用域的资源类型会在其名字空间被删除时也被删除,
170
+ 并且对该资源类型的访问是由定义在名字空间域中的授权检查来控制的。
172
171
172
+ 你还可以访问资源集合(例如:列出所有 Node)。以下路径用于检索集合和资源:
173
173
174
174
* 集群作用域的资源:
175
175
* ` GET /apis/GROUP/VERSION/RESOURCETYPE ` - 返回指定资源类型的资源的集合
@@ -185,8 +185,7 @@ Since a namespace is a cluster-scoped resource type, you can retrieve the list
185
185
a particular namespace with `GET /api/v1/namespaces/NAME`.
186
186
-->
187
187
由于名字空间本身是一个集群作用域的资源类型,你可以通过 ` GET /api/v1/namespaces/ `
188
- 检视所有名字空间的列表(“集合”),使用 ` GET /api/v1/namespaces/NAME ` 查看特定名字空间的
189
- 详细信息。
188
+ 检视所有名字空间的列表(“集合”),使用 ` GET /api/v1/namespaces/NAME ` 查看特定名字空间的详细信息。
190
189
191
190
<!--
192
191
* Cluster-scoped subresource: `GET /apis/GROUP/VERSION/RESOURCETYPE/NAME/SUBRESOURCE`
@@ -201,8 +200,7 @@ virtual resource type would be used if that becomes necessary.
201
200
* 名字空间作用域的子资源:` GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME/SUBRESOURCE `
202
201
203
202
取决于对象是什么,每个子资源所支持的动词有所不同 - 参见 [ API 文档] ( /zh-cn/docs/reference/kubernetes-api/ ) 以了解更多信息。
204
- 跨多个资源来访问其子资源是不可能的 - 如果需要这一能力,则通常意味着需要一种
205
- 新的虚拟资源类型了。
203
+ 跨多个资源来访问其子资源是不可能的 - 如果需要这一能力,则通常意味着需要一种新的虚拟资源类型了。
206
204
207
205
<!--
208
206
## Efficient detection of changes
@@ -431,8 +429,8 @@ of 500 pods at a time, request those chunks as follows:
431
429
并在无法返回更多结果时返回 ` 410 Gone ` 代码。
432
430
这时,客户端需要从头开始执行上述检视操作或者忽略 ` limit ` 参数。
433
431
434
- 例如,如果集群上有 1253 个 Pod,客户端希望每次收到包含至多 500 个 Pod 的
435
- 数据块 ,它应按下面的步骤来请求数据块:
432
+ 例如,如果集群上有 1253 个 Pod,客户端希望每次收到包含至多 500 个 Pod
433
+ 的数据块 ,它应按下面的步骤来请求数据块:
436
434
437
435
<!--
438
436
1. List all of the pods on a cluster, retrieving up to 500 pods each time.
@@ -667,8 +665,7 @@ had to be in place for types unrecognized by a client.
667
665
# # 以表格形式接收资源 {#receiving-resources-as-tables}
668
666
669
667
当你执行 `kubectl get` 时,默认的输出格式是特定资源类型的一个或多个实例的简单表格形式。
670
- 过去,客户端需要重复 `kubectl` 中所实现的表格输出和描述输出逻辑,以执行
671
- 简单的对象列表操作。
668
+ 过去,客户端需要重复 `kubectl` 中所实现的表格输出和描述输出逻辑,以执行简单的对象列表操作。
672
669
该方法的一些限制包括处理某些对象时的不可忽视逻辑。
673
670
此外,API 聚合或第三方资源提供的类型在编译时是未知的。
674
671
这意味着必须为客户端无法识别的类型提供通用实现。
@@ -685,8 +682,8 @@ For example, list all of the pods on a cluster in the Table format.
685
682
-->
686
683
为了避免上述各种潜在的局限性,客户端可以请求服务器端返回对象的表格(Table)
687
684
表现形式,从而将打印输出的特定细节委托给服务器。
688
- Kubernetes API 实现标准的 HTTP 内容类型(Content Type)协商:为 `GET` 调用
689
- 传入一个值为 `application/json;as=Table;g=meta.k8s.io;v=v1` 的 `Accept`
685
+ Kubernetes API 实现标准的 HTTP 内容类型(Content Type)协商:为 `GET`
686
+ 调用传入一个值为 `application/json;as=Table;g=meta.k8s.io;v=v1` 的 `Accept`
690
687
头部即可请求服务器以 Table 的内容类型返回对象。
691
688
692
689
例如,以 Table 格式列举集群中所有 Pod:
@@ -713,8 +710,8 @@ For API resource types that do not have a custom Table definition known to the c
713
710
plane, the API server returns a default Table response that consists of the resource's
714
711
` name` and `creationTimestamp` fields.
715
712
-->
716
- 对于在控制平面上不存在定制的 Table 定义的 API 资源类型而言,服务器会返回
717
- 一个默认的 Table 响应,其中包含资源的 `name` 和 `creationTimestamp` 字段。
713
+ 对于在控制平面上不存在定制的 Table 定义的 API 资源类型而言,服务器会返回一个默认的
714
+ Table 响应,其中包含资源的 `name` 和 `creationTimestamp` 字段。
718
715
719
716
` ` ` console
720
717
GET /apis/crd.example.com/v1alpha1/namespaces/default/resources
@@ -808,7 +805,7 @@ For example:
808
805
<!--
809
806
1. List all of the pods on a cluster in Protobuf format.
810
807
-->
811
- 1. 以 Protobuf 格式列举集群上的所有 Pods :
808
+ 1. 以 Protobuf 格式列举集群上的所有 Pod :
812
809
813
810
` ` ` console
814
811
GET /api/v1/pods
@@ -871,7 +868,7 @@ describes the encoding and type of the underlying object and then contains the o
871
868
872
869
The wrapper format is :
873
870
-->
874
- # ## Kubernetes Protobuf encoding {#protobuf-encoding}
871
+ # ## Kubernetes Protobuf 编码 {#protobuf-encoding}
875
872
876
873
Kubernetes 使用封套形式来对 Protobuf 响应进行编码。
877
874
封套外层由 4 个字节的特殊数字开头,便于从磁盘文件或 etcd 中辩识 Protobuf
@@ -928,7 +925,7 @@ An encoded Protobuf message with the following IDL:
928
925
optional string contentEncoding = 3;
929
926
930
927
// contentType 包含 raw 数据所采用的序列化方法。
931
- // 未设置此值意味着 application/vnd.kubernetes.protobuf,且通常被忽略
928
+ // 未设置此值意味着 application/vnd.kubernetes.protobuf,且通常被忽略
932
929
optional string contentType = 4;
933
930
}
934
931
@@ -940,15 +937,15 @@ An encoded Protobuf message with the following IDL:
940
937
}
941
938
` ` `
942
939
940
+ {{< note >}}
943
941
<!--
944
942
Clients that receive a response in `application/vnd.kubernetes.protobuf` that does
945
943
not match the expected prefix should reject the response, as future versions may need
946
944
to alter the serialization format in an incompatible way and will do so by changing
947
945
the prefix.
948
946
-->
949
- {{< note >}}
950
- 收到 `application/vnd.kubernetes.protobuf` 格式响应的客户端在响应与预期的前缀
951
- 不匹配时应该拒绝响应,因为将来的版本可能需要以某种不兼容的方式更改序列化格式,
947
+ 收到 `application/vnd.kubernetes.protobuf` 格式响应的客户端在响应与预期的前缀不匹配时应该拒绝响应,
948
+ 因为将来的版本可能需要以某种不兼容的方式更改序列化格式,
952
949
并且这种更改是通过变更前缀完成的。
953
950
{{< /note >}}
954
951
@@ -967,7 +964,6 @@ When you **delete** a resource this takes place in two phases.
967
964
1. 终结(finalization)
968
965
2. 移除
969
966
970
-
971
967
` ` ` yaml
972
968
{
973
969
"kind": "ConfigMap",
@@ -1260,12 +1256,12 @@ If the non-dry-run version of a request would trigger an admission controller th
1260
1256
side effects, the request will be failed rather than risk an unwanted side effect. All
1261
1257
built in admission control plugins support dry-run. Additionally, admission webhooks can
1262
1258
declare in their
1263
- [configuration object](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#webhook-v1beta1 -admissionregistration-k8s-io)
1259
+ [configuration object](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#validatingwebhook-v1 -admissionregistration-k8s-io)
1264
1260
that they do not have side effects, by setting their `sideEffects` field to `None`.
1265
1261
-->
1266
1262
如果请求的非试运行版本会触发具有副作用的准入控制器,则该请求将失败,而不是冒不希望的副作用的风险。
1267
1263
所有内置准入控制插件都支持试运行。
1268
- 此外,准入 Webhook 还可以设置[配置对象](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#webhook-v1beta1 -admissionregistration-k8s-io)
1264
+ 此外,准入 Webhook 还可以设置[配置对象](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#validatingwebhook-v1 -admissionregistration-k8s-io)
1269
1265
的 `sideEffects` 字段为 `None`,借此声明它们没有副作用。
1270
1266
1271
1267
<!--
@@ -1312,9 +1308,8 @@ Some values of an object are typically generated before the object is persisted.
1312
1308
-->
1313
1309
# ## 生成值 {#generated-values}
1314
1310
1315
- 对象的某些值通常是在对象被写入数据库之前生成的。很重要的一点是不要依赖试运行
1316
- 请求为这些字段所设置的值,因为试运行模式下所得到的这些值与真实请求所获得的
1317
- 值很可能不同。这类字段有:
1311
+ 对象的某些值通常是在对象被写入数据库之前生成的。很重要的一点是不要依赖试运行请求为这些字段所设置的值,
1312
+ 因为试运行模式下所得到的这些值与真实请求所获得的值很可能不同。这类字段有:
1318
1313
1319
1314
* `name`:如果设置了 `generateName` 字段,则 `name` 会获得一个唯一的随机名称
1320
1315
* `creationTimestamp` / `deletionTimestamp`:记录对象的创建/删除时间
@@ -1414,12 +1409,11 @@ stream for a **watch**, or when using **list** to enumerate resources.
1414
1409
1415
1410
客户端在资源中查找资源版本,这些资源包括来自用于 **watch** 的响应流资源,或者使用 **list** 枚举的资源。
1416
1411
1417
- [v1.meta/ObjectMeta](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#objectmeta-v1-meta) - 资源
1418
- 的 `metadata.resourceVersion` 值标明该实例上次被更改时的资源版本。
1412
+ [v1.meta/ObjectMeta](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#objectmeta-v1-meta) -
1413
+ 资源的 `metadata.resourceVersion` 值标明该实例上次被更改时的资源版本。
1419
1414
1420
- [v1.meta/ListMeta](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#listmeta-v1-meta) - 资源集合
1421
- 即 **list** 操作的响应)的 `metadata.resourceVersion` 所标明的是 list
1422
- 响应被构造时的资源版本。
1415
+ [v1.meta/ListMeta](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#listmeta-v1-meta) - 资源集合即
1416
+ **list** 操作的响应)的 `metadata.resourceVersion` 所标明的是 list 响应被构造时的资源版本。
1423
1417
1424
1418
<!--
1425
1419
# ## `resourceVersion` parameters in query strings {#the-resourceversion-parameter}
@@ -1462,7 +1456,6 @@ For **get** and **list**, the semantics of `resourceVersion` are:
1462
1456
|-----------------------|---------------------|----------------------------------------|
1463
1457
| 最新版本 | 任何版本 | 不老于给定版本 |
1464
1458
1465
-
1466
1459
**list:**
1467
1460
1468
1461
<!--
@@ -1491,14 +1484,13 @@ quorum read to be served.
1491
1484
1492
1485
Setting the `resourceVersionMatch` parameter without setting `resourceVersion` is not valid.
1493
1486
1494
-
1495
1487
This table explains the behavior of **list** requests with various combinations of
1496
1488
`resourceVersion` and `resourceVersionMatch` :
1497
1489
-->
1498
1490
除非你对一致性有着非常强烈的需求,使用 `resourceVersionMatch=NotOlderThan`
1499
1491
同时为 `resourceVersion` 设定一个已知值是优选的交互方式,因为与不设置
1500
- ` resourceVersion` 和 `resourceVersionMatch` 相比,这种配置可以取得更好的
1501
- 集群性能和可扩缩性。 后者需要提供带票选能力的读操作。
1492
+ ` resourceVersion` 和 `resourceVersionMatch` 相比,这种配置可以取得更好的集群性能和可扩缩性。
1493
+ 后者需要提供带票选能力的读操作。
1502
1494
1503
1495
设置 `resourceVersionMatch` 参数而不设置 `resourceVersion` 参数是不合法的。
1504
1496
@@ -1521,13 +1513,13 @@ This table explains the behavior of **list** requests with various combinations
1521
1513
1522
1514
| resourceVersionMatch 参数 | 分页参数 | resourceVersion 未设置 | resourceVersion="0" | resourceVersion="\<非零值\>" |
1523
1515
|-----------------------------------------|---------------------------------|-------------------------|-----------------------------------------|----------------------------------|
1524
- | _未设置_ | _limit 未设置_ | 最新版本 | 任意版本 | 不老于指定版本 |
1525
- | _未设置_ | limit=\<n\>, _continue 未设置_ | 最新版本 | 任意版本 | 精确匹配 |
1526
- | _未设置_ | limit=\<n\>, continue=\<token\> | 从 token 开始、精确匹配 | 非法请求,视为从 token 开始、精确匹配 | 非法请求,返回 HTTP `400 Bad Request` |
1527
- | `resourceVersionMatch=Exact` [1] | _limit 未设置_ | 非法请求 | 非法请求 | 精确匹配 |
1528
- | `resourceVersionMatch=Exact` [1] | limit=\<n\>, _continue 未设置_ | 非法请求 | 非法请求 | 精确匹配 |
1529
- | `resourceVersionMatch=NotOlderThan` [1] | _limit 未设置_ | 非法请求 | 任意版本 | 不老于指定版本 |
1530
- | `resourceVersionMatch=NotOlderThan` [1] | limit=\<n\>, _continue 未设置_ | 非法请求 | 任意版本 | 不老于指定版本 |
1516
+ | **未设置** | **limit 未设置** | 最新版本 | 任意版本 | 不老于指定版本 |
1517
+ | **未设置** | limit=\<n\>, **continue 未设置** | 最新版本 | 任意版本 | 精确匹配 |
1518
+ | **未设置** | limit=\<n\>, continue=\<token\> | 从 token 开始、精确匹配 | 非法请求,视为从 token 开始、精确匹配 | 非法请求,返回 HTTP `400 Bad Request` |
1519
+ | `resourceVersionMatch=Exact` [1] | **limit 未设置** | 非法请求 | 非法请求 | 精确匹配 |
1520
+ | `resourceVersionMatch=Exact` [1] | limit=\<n\>, **continue 未设置** | 非法请求 | 非法请求 | 精确匹配 |
1521
+ | `resourceVersionMatch=NotOlderThan` [1] | **limit 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
1522
+ | `resourceVersionMatch=NotOlderThan` [1] | limit=\<n\>, **continue 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
1531
1523
1532
1524
{{< /table >}}
1533
1525
@@ -1609,6 +1601,8 @@ Continue Token, Exact
1609
1601
: 返回初始分页 **list** 调用的资源版本的数据。
1610
1602
返回的 _Continue 令牌_ 负责跟踪最初提供的资源版本,最初提供的资源版本用于在初始分页 **list** 之后的所有分页 **list** 中。
1611
1603
1604
+
1605
+ {{< note >}}
1612
1606
<!--
1613
1607
When you **list** resources and receive a collection response, the response includes the
1614
1608
[metadata](/docs/reference/generated/kubernetes-api/v1.21/#listmeta-v1-meta) of the collection as
@@ -1617,8 +1611,6 @@ for each item in that collection. For individual objects found within a collecti
1617
1611
` .metadata.resourceVersion` tracks when that object was last updated, and not how up-to-date
1618
1612
the object is when served.
1619
1613
-->
1620
-
1621
- {{< note >}}
1622
1614
当你 **list** 资源并收到集合响应时,
1623
1615
响应包括集合的[元数据](/docs/reference/generated/kubernetes-api/v1.21/#listmeta-v1-meta)
1624
1616
以及该集合中每个项目的[对象元数据](/docs/reference/generated/kubernetes-api/v1.21/#listmeta-v1-meta)。
@@ -1645,7 +1637,6 @@ example, the client might fall back to a request with `limit` set.
1645
1637
客户端必须验证集合的 `.metadata.resourceVersion` 是否与请求的 `resourceVersion` 匹配,
1646
1638
并处理不匹配的情况。例如,客户端可能会退回到设置了限制的请求。
1647
1639
1648
-
1649
1640
<!--
1650
1641
# ## Semantics for **watch**
1651
1642
@@ -1754,11 +1745,11 @@ on whether a request is served from cache or not, the API server may reply with
1754
1745
服务器不需要提供所有老的资源版本,在客户端请求的是早于服务器端所保留版本的
1755
1746
` resourceVersion` 时,可以返回 HTTP `410 (Gone)` 状态码。
1756
1747
客户端必须能够容忍 `410 (Gone)` 响应。
1757
- 参阅[高效检测变更](#efficient-detection-of-changes)以了解如何在监测资源时
1758
- 处理 `410 (Gone)` 响应。
1748
+ 参阅[高效检测变更](#efficient-detection-of-changes)以了解如何在监测资源时处理
1749
+ ` 410 (Gone)` 响应。
1759
1750
1760
- 如果所请求的 `resourceVersion` 超出了可应用的 `limit`,那么取决于请求是否
1761
- 是通过高速缓存来满足的 ,API 服务器可能会返回一个 `410 Gone` HTTP 响应。
1751
+ 如果所请求的 `resourceVersion` 超出了可应用的 `limit`,
1752
+ 那么取决于请求是否是通过高速缓存来满足的 ,API 服务器可能会返回一个 `410 Gone` HTTP 响应。
1762
1753
1763
1754
<!--
1764
1755
# ## Unavailable resource versions
@@ -1795,4 +1786,4 @@ available.
1795
1786
kube-apiserver 还会使用 “Too large resource version” 消息额外标识其错误响应。
1796
1787
1797
1788
如果你对无法识别的资源版本发出 **watch** 请求,
1798
- API 服务器可能会无限期地等待(直到请求超时)资源版本变为可用。
1789
+ API 服务器可能会无限期地等待(直到请求超时)资源版本变为可用。
0 commit comments