Skip to content

Commit 391d609

Browse files
committed
[zh-cn]sync api-concepts
Signed-off-by: xin.li <xin.li@daocloud.io>
1 parent a4aedca commit 391d609

File tree

1 file changed

+68
-39
lines changed

1 file changed

+68
-39
lines changed

content/zh-cn/docs/reference/using-api/api-concepts.md

Lines changed: 68 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ weight: 20
1414
-->
1515

1616
<!-- overview -->
17+
1718
<!--
1819
The Kubernetes API is a resource-based (RESTful) programmatic interface
1920
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.
119120
Almost all object resource types support the standard HTTP verbs - GET, POST, PUT, PATCH,
120121
and DELETE. Kubernetes also uses its own verbs, which are often written in lowercase to distinguish
121122
them from HTTP verbs.
123+
-->
124+
### API 动词 {#api-verbs}
122125

126+
几乎所有对象资源类型都支持标准 HTTP 动词 - GET、POST、PUT、PATCH 和 DELETE。
127+
Kubernetes 也使用自己的动词,这些动词通常写成小写,以区别于 HTTP 动词。
128+
129+
<!--
123130
Kubernetes uses the term **list** to describe the action of returning a [collection](#collections) of
124131
resources, to distinguish it from retrieving a single resource which is usually called
125132
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
130137
based on the state of the existing object. An **update** is different from a **patch**; the
131138
HTTP verb for a **patch** is PATCH.
132139
-->
133-
### API 动词 {#api-verbs}
134-
135-
几乎所有对象资源类型都支持标准 HTTP 动词 - GET、POST、PUT、PATCH 和 DELETE。
136-
Kubernetes 也使用自己的动词,这些动词通常写成小写,以区别于 HTTP 动词。
137-
138140
Kubernetes 使用术语 **list** 来描述返回资源[集合](#collections)的操作,
139141
以区别于检索单个资源、通常名为 **get** 的操作。
140142
如果你发送带有 `?watch` 查询参数的 HTTP GET 请求,
@@ -181,7 +183,15 @@ The following paths are used to retrieve collections and resources:
181183
182184
* `GET /apis/GROUP/VERSION/RESOURCETYPE` - return the collection of resources of the resource type
183185
* `GET /apis/GROUP/VERSION/RESOURCETYPE/NAME` - return the resource with NAME under the resource type
186+
-->
187+
你还可以访问资源集合(例如:列出所有 Node)。以下路径用于检索集合和资源:
184188

189+
* 集群作用域的资源:
190+
191+
* `GET /apis/GROUP/VERSION/RESOURCETYPE` - 返回指定资源类型的资源的集合
192+
* `GET /apis/GROUP/VERSION/RESOURCETYPE/NAME` - 返回指定资源类型下名称为 NAME 的资源
193+
194+
<!--
185195
* Namespace-scoped resources:
186196
187197
* `GET /apis/GROUP/VERSION/RESOURCETYPE` - return the collection of all
@@ -191,13 +201,6 @@ The following paths are used to retrieve collections and resources:
191201
* `GET /apis/GROUP/VERSION/namespaces/NAMESPACE/RESOURCETYPE/NAME` -
192202
return the instance of the resource type with NAME in NAMESPACE
193203
-->
194-
你还可以访问资源集合(例如:列出所有 Node)。以下路径用于检索集合和资源:
195-
196-
* 集群作用域的资源:
197-
198-
* `GET /apis/GROUP/VERSION/RESOURCETYPE` - 返回指定资源类型的资源的集合
199-
* `GET /apis/GROUP/VERSION/RESOURCETYPE/NAME` - 返回指定资源类型下名称为 NAME 的资源
200-
201204
* 名字空间作用域的资源:
202205

203206
* `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
769772
重新执行 **get** 或者 **list** 操作,
770773
并基于新返回的 `resourceVersion` 来开始新的 **watch** 操作。
771774

772-
对于订阅集合,Kubernetes 客户端库通常会为 **list** -然后- **watch** 的逻辑提供某种形式的标准工具。
775+
对于订阅集合,Kubernetes 客户端库通常会为 **list** - 然后 - **watch** 的逻辑提供某种形式的标准工具。
773776
(在 Go 客户端库中,这称为 `反射器(Reflector)`,位于 `k8s.io/client-go/tools/cache` 包中。)
774777

775778
<!--
@@ -1447,7 +1450,8 @@ setting the command line option `--feature-gates=AllowUnsafeMalformedObjectDelet
14471450
The user performing the force **delete** operation must have the privileges to do both
14481451
the **delete** and **unsafe-delete-ignore-read-errors** verbs on the given resource.
14491452
-->
1450-
执行强制**删除**操作的用户必须拥有对给定资源执行 **delete****unsafe-delete-ignore-read-errors** 动作的权限。
1453+
执行强制**删除**操作的用户必须拥有对给定资源执行 **delete**
1454+
**unsafe-delete-ignore-read-errors** 动作的权限。
14511455
{{< /note >}}
14521456

14531457
<!--
@@ -2225,29 +2229,29 @@ This table explains the behavior of **list** requests with various combinations
22252229
下表解释了具有各种 `resourceVersion` 和 `resourceVersionMatch` 组合的 **list** 请求的行为:
22262230

22272231
<!--
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 |
22372241

22382242
{{</* /table */>}}
22392243
-->
22402244
{{< table caption="list 操作的 resourceVersionMatch 与分页参数" >}}
22412245

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 未设置** | 非法请求 | 任意版本 | 不老于指定版本 |
22512255

22522256
{{< /table >}}
22532257

@@ -2272,12 +2276,14 @@ Any
22722276
for the request to return data at a much older resource version that the client has previously
22732277
observed, particularly in high availability configurations, due to partitions or stale
22742278
caches. Clients that cannot tolerate this should not use this semantic.
2279+
Always served from _watch cache_, improving performance and reducing etcd load.
22752280
-->
22762281
任意版本
22772282
: 返回任何资源版本的数据。最新可用资源版本优先,但不需要强一致性;
22782283
可以提供任何资源版本的数据。由于分区或过时的缓存,
22792284
请求可能返回客户端先前观察到的更旧资源版本的数据,特别是在高可用性配置中。
22802285
不能容忍这种情况的客户不应该使用这种语义。
2286+
始终通过**监视缓存**提供服务,提高性能并减少 etcd 负载。
22812287

22822288
<!--
22832289
Most recent
@@ -2306,13 +2312,15 @@ Not older than
23062312
guarantees that the collection's `.metadata.resourceVersion` is not older than the requested
23072313
`resourceVersion`, but does not make any guarantee about the `.metadata.resourceVersion` of any
23082314
of the items in that collection.
2315+
Always served from _watch cache_, improving performance and reducing etcd load.
23092316
-->
23102317
不老于指定版本
23112318
: 返回数据至少与提供的 `resourceVersion` 一样新。
23122319
最新的可用数据是首选,但可以提供不早于提供的 `resourceVersion` 的任何数据。
23132320
对于对遵守 `resourceVersionMatch` 参数的服务器的 **list** 请求,
23142321
这保证了集合的 `.metadata.resourceVersion` 不早于请求的 `resourceVersion`,
23152322
但不保证该集合中任何项目的 `.metadata.resourceVersion`。
2323+
始终通过**监视缓存**提供服务,提高性能并减少 etcd 负载。
23162324

23172325
<!--
23182326
Exact
@@ -2322,20 +2330,41 @@ Exact
23222330
is the same as the `resourceVersion` you requested in the query string. That guarantee does
23232331
not apply to the `.metadata.resourceVersion` of any items within that collection.
23242332

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.
23292337
-->
23302338
精确匹配
23312339
: 以提供的确切资源版本返回数据。如果提供的 `resourceVersion` 不可用,
23322340
则服务器以 HTTP `410 Gone` 响应。对于对支持 `resourceVersionMatch` 参数的服务器的 **list** 请求,
23332341
这可以保证集合的 `.metadata.resourceVersion` 与你在查询字符串中请求的 `resourceVersion` 相同。
23342342
该保证不适用于该集合中任何项目的 `.metadata.resourceVersion`。
23352343

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。
23392368

23402369
{{< note >}}
23412370
<!--

0 commit comments

Comments
 (0)