@@ -14,6 +14,7 @@ weight: 20
14
14
-->
15
15
16
16
<!-- overview -->
17
+
17
18
<!--
18
19
The Kubernetes API is a resource-based (RESTful) programmatic interface
19
20
provided via HTTP. It supports retrieving, creating, updating, and deleting
@@ -119,7 +120,13 @@ example: Nodes), and so their names must be unique across the whole cluster.
119
120
Almost all object resource types support the standard HTTP verbs - GET, POST, PUT, PATCH,
120
121
and DELETE. Kubernetes also uses its own verbs, which are often written in lowercase to distinguish
121
122
them from HTTP verbs.
123
+ -->
124
+ ### API 动词 {#api-verbs}
122
125
126
+ 几乎所有对象资源类型都支持标准 HTTP 动词 - GET、POST、PUT、PATCH 和 DELETE。
127
+ Kubernetes 也使用自己的动词,这些动词通常写成小写,以区别于 HTTP 动词。
128
+
129
+ <!--
123
130
Kubernetes uses the term **list** to describe the action of returning a [collection](#collections) of
124
131
resources, to distinguish it from retrieving a single resource which is usually called
125
132
a **get**. If you sent an HTTP GET request with the `?watch` query parameter,
@@ -130,11 +137,6 @@ For PUT requests, Kubernetes internally classifies these as either **create** or
130
137
based on the state of the existing object. An **update** is different from a **patch**; the
131
138
HTTP verb for a **patch** is PATCH.
132
139
-->
133
- ### API 动词 {#api-verbs}
134
-
135
- 几乎所有对象资源类型都支持标准 HTTP 动词 - GET、POST、PUT、PATCH 和 DELETE。
136
- Kubernetes 也使用自己的动词,这些动词通常写成小写,以区别于 HTTP 动词。
137
-
138
140
Kubernetes 使用术语 ** list** 来描述返回资源[ 集合] ( #collections ) 的操作,
139
141
以区别于检索单个资源、通常名为 ** get** 的操作。
140
142
如果你发送带有 ` ?watch ` 查询参数的 HTTP GET 请求,
@@ -181,7 +183,15 @@ The following paths are used to retrieve collections and resources:
181
183
182
184
* `GET /apis/GROUP/VERSION/RESOURCETYPE` - return the collection of resources of the resource type
183
185
* `GET /apis/GROUP/VERSION/RESOURCETYPE/NAME` - return the resource with NAME under the resource type
186
+ -->
187
+ 你还可以访问资源集合(例如:列出所有 Node)。以下路径用于检索集合和资源:
184
188
189
+ * 集群作用域的资源:
190
+
191
+ * ` GET /apis/GROUP/VERSION/RESOURCETYPE ` - 返回指定资源类型的资源的集合
192
+ * ` GET /apis/GROUP/VERSION/RESOURCETYPE/NAME ` - 返回指定资源类型下名称为 NAME 的资源
193
+
194
+ <!--
185
195
* Namespace-scoped resources:
186
196
187
197
* `GET /apis/GROUP/VERSION/RESOURCETYPE` - return the collection of all
@@ -191,13 +201,6 @@ The following paths are used to retrieve collections and resources:
191
201
* `GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME` -
192
202
return the instance of the resource type with NAME in NAMESPACE
193
203
-->
194
- 你还可以访问资源集合(例如:列出所有 Node)。以下路径用于检索集合和资源:
195
-
196
- * 集群作用域的资源:
197
-
198
- * ` GET /apis/GROUP/VERSION/RESOURCETYPE ` - 返回指定资源类型的资源的集合
199
- * ` GET /apis/GROUP/VERSION/RESOURCETYPE/NAME ` - 返回指定资源类型下名称为 NAME 的资源
200
-
201
204
* 名字空间作用域的资源:
202
205
203
206
* ` GET /apis/GROUP/VERSION/RESOURCETYPE ` - 返回所有名字空间中指定资源类型的全部实例的集合
@@ -769,7 +772,7 @@ this is called a `Reflector` and is located in the `k8s.io/client-go/tools/cache
769
772
重新执行 ** get** 或者 ** list** 操作,
770
773
并基于新返回的 ` resourceVersion ` 来开始新的 ** watch** 操作。
771
774
772
- 对于订阅集合,Kubernetes 客户端库通常会为 ** list** -然后 - ** watch** 的逻辑提供某种形式的标准工具。
775
+ 对于订阅集合,Kubernetes 客户端库通常会为 ** list** - 然后 - ** watch** 的逻辑提供某种形式的标准工具。
773
776
(在 Go 客户端库中,这称为 ` 反射器(Reflector) ` ,位于 ` k8s.io/client-go/tools/cache ` 包中。)
774
777
775
778
<!--
@@ -1447,7 +1450,8 @@ setting the command line option `--feature-gates=AllowUnsafeMalformedObjectDelet
1447
1450
The user performing the force **delete** operation must have the privileges to do both
1448
1451
the **delete** and **unsafe-delete-ignore-read-errors** verbs on the given resource.
1449
1452
-->
1450
- 执行强制** 删除** 操作的用户必须拥有对给定资源执行 ** delete** 和 ** unsafe-delete-ignore-read-errors** 动作的权限。
1453
+ 执行强制** 删除** 操作的用户必须拥有对给定资源执行 ** delete** 和
1454
+ ** unsafe-delete-ignore-read-errors** 动作的权限。
1451
1455
{{< /note >}}
1452
1456
1453
1457
<!--
@@ -2225,29 +2229,29 @@ This table explains the behavior of **list** requests with various combinations
2225
2229
下表解释了具有各种 `resourceVersion` 和 `resourceVersionMatch` 组合的 **list** 请求的行为:
2226
2230
2227
2231
<!--
2228
- | resourceVersionMatch param | paging params | resourceVersion not set | resourceVersion="0" | resourceVersion="{value other than 0}" |
2229
- |----------------------------| ---------------|-------------------------|---------------------|----------------------------------------|
2230
- | _unset_ | _limit unset_ | Most Recent | Any | Not older than |
2231
- | _unset_ | limit=\<n\>, _continue unset_ | Most Recent | Any | Exact |
2232
- | _unset_ | limit=\<n\>, continue=\<token\>| Continue Token, Exact | Invalid, treated as Continue Token, Exact | Invalid, HTTP `400 Bad Request` |
2233
- | `resourceVersionMatch=Exact` | _limit unset_ | Invalid | Invalid | Exact |
2234
- | `resourceVersionMatch=Exact` | limit=\<n\>, _continue unset_ | Invalid | Invalid | Exact |
2235
- | `resourceVersionMatch=NotOlderThan` | _limit unset_ | Invalid | Any | Not older than |
2236
- | `resourceVersionMatch=NotOlderThan` | limit=\<n\>, _continue unset_ | Invalid | Any | Not older than |
2232
+ | resourceVersionMatch param | paging params | resourceVersion not set | resourceVersion="0" | resourceVersion="{value other than 0}" |
2233
+ |-------------------------------------|----------------- ---------------|-------------------------|---------------------|----------------------------------------|
2234
+ | _unset_ | _limit unset_ | Most Recent | Any | Not older than |
2235
+ | _unset_ | limit=\<n\>, _continue unset_ | Most Recent | Any | Exact |
2236
+ | _unset_ | limit=\<n\>, continue=\<token\>| Continuation | Continuation | Invalid, HTTP `400 Bad Request` |
2237
+ | `resourceVersionMatch=Exact` | _limit unset_ | Invalid | Invalid | Exact |
2238
+ | `resourceVersionMatch=Exact` | limit=\<n\>, _continue unset_ | Invalid | Invalid | Exact |
2239
+ | `resourceVersionMatch=NotOlderThan` | _limit unset_ | Invalid | Any | Not older than |
2240
+ | `resourceVersionMatch=NotOlderThan` | limit=\<n\>, _continue unset_ | Invalid | Any | Not older than |
2237
2241
2238
2242
{{</* /table */>}}
2239
2243
-->
2240
2244
{{< table caption="list 操作的 resourceVersionMatch 与分页参数" >}}
2241
2245
2242
- | resourceVersionMatch 参数 | 分页参数 | resourceVersion 未设置 | resourceVersion="0" | resourceVersion="\<非零值\>" |
2243
- |--------------------------|---------|-----------------------| ---------------------|-----------------------------|
2244
- | **未设置** | **limit 未设置** | 最新版本 | 任意版本 | 不老于指定版本 |
2245
- | **未设置** | limit=\<n\>, **continue 未设置** | 最新版本 | 任意版本 | 精确匹配 |
2246
- | **未设置** | limit=\<n\>, continue=\<token\> | 从 token 开始、精确匹配 | 非法请求,视为从 token 开始、精确匹配 | 非法请求,返回 HTTP `400 Bad Request` |
2247
- | `resourceVersionMatch=Exact` [1] | **limit 未设置** | 非法请求 | 非法请求 | 精确匹配 |
2248
- | `resourceVersionMatch=Exact` [1] | limit=\<n\>, **continue 未设置** | 非法请求 | 非法请求 | 精确匹配 |
2249
- | `resourceVersionMatch=NotOlderThan` [1] | **limit 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
2250
- | `resourceVersionMatch=NotOlderThan` [1] | limit=\<n\>, **continue 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
2246
+ | resourceVersionMatch 参数 | 分页参数 | resourceVersion 未设置 | resourceVersion="0" | resourceVersion="\<非零值\>" |
2247
+ |--------------------------------------------- |--------------------------------- |-----------------------------------|--------------- ---------------------|-----------------------------|
2248
+ | **未设置** | **limit 未设置** | 最新版本 | 任意版本 | 不老于指定版本 |
2249
+ | **未设置** | limit=\<n\>, **continue 未设置** | 最新版本 | 任意版本 | 精确匹配 | |
2250
+ | **未设置** | limit=\<n\>, continue=\<token\> | 从 token 开始、精确匹配 | 非法请求,视为从 token 开始、精确匹配 | 非法请求,返回 HTTP `400 Bad Request` | |
2251
+ | `resourceVersionMatch=Exact` [1] | **limit 未设置** | 非法请求 | 非法请求 | 精确匹配 |
2252
+ | `resourceVersionMatch=Exact` [1] | limit=\<n\>, **continue 未设置** | 非法请求 | 非法请求 | 精确匹配 |
2253
+ | `resourceVersionMatch=NotOlderThan` [1] | **limit 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
2254
+ | `resourceVersionMatch=NotOlderThan` [1] | limit=\<n\>, **continue 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
2251
2255
2252
2256
{{< /table >}}
2253
2257
@@ -2272,12 +2276,14 @@ Any
2272
2276
for the request to return data at a much older resource version that the client has previously
2273
2277
observed, particularly in high availability configurations, due to partitions or stale
2274
2278
caches. Clients that cannot tolerate this should not use this semantic.
2279
+ Always served from _watch cache_, improving performance and reducing etcd load.
2275
2280
-->
2276
2281
任意版本
2277
2282
: 返回任何资源版本的数据。最新可用资源版本优先,但不需要强一致性;
2278
2283
可以提供任何资源版本的数据。由于分区或过时的缓存,
2279
2284
请求可能返回客户端先前观察到的更旧资源版本的数据,特别是在高可用性配置中。
2280
2285
不能容忍这种情况的客户不应该使用这种语义。
2286
+ 始终通过**监视缓存**提供服务,提高性能并减少 etcd 负载。
2281
2287
2282
2288
<!--
2283
2289
Most recent
@@ -2306,13 +2312,15 @@ Not older than
2306
2312
guarantees that the collection's `.metadata.resourceVersion` is not older than the requested
2307
2313
` resourceVersion` , but does not make any guarantee about the `.metadata.resourceVersion` of any
2308
2314
of the items in that collection.
2315
+ Always served from _watch cache_, improving performance and reducing etcd load.
2309
2316
-->
2310
2317
不老于指定版本
2311
2318
: 返回数据至少与提供的 `resourceVersion` 一样新。
2312
2319
最新的可用数据是首选,但可以提供不早于提供的 `resourceVersion` 的任何数据。
2313
2320
对于对遵守 `resourceVersionMatch` 参数的服务器的 **list** 请求,
2314
2321
这保证了集合的 `.metadata.resourceVersion` 不早于请求的 `resourceVersion`,
2315
2322
但不保证该集合中任何项目的 `.metadata.resourceVersion`。
2323
+ 始终通过**监视缓存**提供服务,提高性能并减少 etcd 负载。
2316
2324
2317
2325
<!--
2318
2326
Exact
@@ -2322,20 +2330,41 @@ Exact
2322
2330
is the same as the `resourceVersion` you requested in the query string. That guarantee does
2323
2331
not apply to the `.metadata.resourceVersion` of any items within that collection.
2324
2332
2325
- Continue Token, Exact
2326
- : Return data at the resource version of the initial paginated **list** call. The returned _continue
2327
- tokens_ are responsible for keeping track of the initially provided resource version for all paginated
2328
- **list** calls after the initial paginated **list** .
2333
+ By default served from _etcd_, but with the `ListFromCacheSnapshot` feature gate enabled,
2334
+ API server will attempt to serve the response from snapshot if available.
2335
+ This improves performance and reduces etcd load. Cache snapshots are kept by default for 75 seconds,
2336
+ so if the provided `resourceVersion` is unavailable, the server will fallback to etcd .
2329
2337
-->
2330
2338
精确匹配
2331
2339
: 以提供的确切资源版本返回数据。如果提供的 `resourceVersion` 不可用,
2332
2340
则服务器以 HTTP `410 Gone` 响应。对于对支持 `resourceVersionMatch` 参数的服务器的 **list** 请求,
2333
2341
这可以保证集合的 `.metadata.resourceVersion` 与你在查询字符串中请求的 `resourceVersion` 相同。
2334
2342
该保证不适用于该集合中任何项目的 `.metadata.resourceVersion`。
2335
2343
2336
- 从 token 开始、精确匹配
2337
- : 返回初始分页 **list** 调用的资源版本的数据。
2338
- 返回的 **Continue 令牌**负责跟踪最初提供的资源版本,最初提供的资源版本用于在初始分页 **list** 之后的所有分页 **list** 中。
2344
+ 默认情况下,由 **etcd** 提供服务,但是当启用了 `ListFromCacheSnapshot` 特性门控时,
2345
+ 如果可用,API 服务器将尝试从快照提供响应。
2346
+ 这提升了性能并减少了 etcd 的负载。缓存快照默认保留 75 秒,
2347
+ 因此如果提供的 `resourceVersion` 不可用,服务器将回退到 etcd。
2348
+
2349
+ <!--
2350
+ Continuation
2351
+ : Return the next page of data for a paginated list request, ensuring consistency with the exact `resourceVersion` established by the initial request in the sequence.
2352
+ Response to **list** requests with limit include _continue token_, that encodes the `resourceVersion` and last observed position from which to resume the list.
2353
+ If the `resourceVersion` in the provided _continue token_ is unavailable, the server responds with HTTP `410 Gone`.
2354
+ By default served from _etcd_, but with the `ListFromCacheSnapshot` feature gate enabled,
2355
+ API server will attempt to serve the response from snapshot if available.
2356
+ This improves performance and reduces etcd load. Cache snapshots are kept by default for 75 seconds,
2357
+ so if the `resourceVersion` in provided _continue token_ is unavailable, the server will fallback to etcd.
2358
+ -->
2359
+ 续页
2360
+ : 为分页列表请求返回下一页数据,确保与序列中初始请求建立的确切 `resourceVersion` 保持一致。
2361
+ 对带有限制的 **list** 请求的响应包括 **continue 令牌**,它编码了 `resourceVersion`
2362
+ 和最后观察到的位置,给出继续列表的起点。
2363
+ 如果提供的 **continue 令牌**中的 `resourceVersion` 不可用,服务器将返回 HTTP `410 Gone`。
2364
+ 默认情况下,由 **etcd** 提供服务,但是当启用了 `ListFromCacheSnapshot` 特性门控时,
2365
+ API 服务器将尝试从快照提供响应(如果缓存快可用)。
2366
+ 这提升了性能并减少了 etcd 的负载。缓存快照默认保留 75 秒,
2367
+ 因此如果提供的 **continue 令牌**中的 `resourceVersion` 不可用,服务器将回退到 etcd。
2339
2368
2340
2369
{{< note >}}
2341
2370
<!--
0 commit comments