Skip to content

Commit

Permalink
[zh] sync /using-api/api-concepts.md
Browse files Browse the repository at this point in the history
  • Loading branch information
windsonsea committed May 29, 2023
1 parent 7ff4609 commit 0ed73f3
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 32 deletions.
50 changes: 50 additions & 0 deletions content/zh-cn/docs/reference/using-api/api-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,56 @@ Content-Type: application/json
<followed by regular watch stream starting from resourceVersion="10245">
```

<!--
## Response compression
-->
## 响应压缩 {#response-compression}

{{< feature-state for_k8s_version="v1.16" state="beta" >}}

<!--
`APIResponseCompression` is an option that allows the API server to compress the responses for **get**
and **list** requests, reducing the network bandwidth and improving the performance of large-scale clusters.
It is enabled by default since Kubernetes 1.16 and it can be disabled by including
`APIResponseCompression=false` in the `--feature-gates` flag on the API server.
-->
`APIResponseCompression` 是一个选项,允许 API 服务器压缩 **get****list** 请求的响应,
减少占用的网络带宽并提高大规模集群的性能。此选项自 Kubernetes 1.16 以来默认启用,
可以通过在 API 服务器上的 `--feature-gates` 标志中包含 `APIResponseCompression=false` 来禁用。

<!--
API response compression can significantly reduce the size of the response, especially for large resources or
[collections](/docs/reference/using-api/api-concepts/#collections).
For example, a **list** request for pods can return hundreds of kilobytes or even megabytes of data,
depending on the number of pods and their attributes. By compressing the response, the network bandwidth
can be saved and the latency can be reduced.
-->
特别是对于大型资源或[集合](/zh-cn/docs/reference/using-api/api-concepts/#collections)
API 响应压缩可以显著减小其响应的大小。例如,针对 Pod 的 **list** 请求可能会返回数百 KB 甚至几 MB 的数据,
具体大小取决于 Pod 数量及其属性。通过压缩响应,可以节省网络带宽并降低延迟。

<!--
To verify if `APIResponseCompression` is working, you can send a **get** or **list** request to the
API server with an `Accept-Encoding` header, and check the response size and headers. For example:
-->
要验证 `APIResponseCompression` 是否正常工作,你可以使用一个 `Accept-Encoding`
头向 API 服务器发送一个 **get****list** 请求,并检查响应大小和头信息。例如:

```console
GET /api/v1/pods
Accept-Encoding: gzip
---
200 OK
Content-Type: application/json
content-encoding: gzip
...
```

<!--
The `content-encoding` header indicates that the response is compressed with `gzip`.
-->
`content-encoding` 头表示响应使用 `gzip` 进行了压缩。

<!--
## Retrieving large results sets in chunks
-->
Expand Down
6 changes: 3 additions & 3 deletions content/zh-cn/docs/reference/using-api/client-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ weight: 30
This page contains an overview of the client libraries for using the Kubernetes
API from various programming languages.
-->
本页面包含基于各种编程语言使用 Kubernetes API 的客户端库概述。

本页面概要介绍了基于各种编程语言使用 Kubernetes API 的客户端库。

<!-- body -->
<!--
Expand Down Expand Up @@ -51,7 +50,8 @@ format to read the credentials and the API Server address.
The following client libraries are officially maintained by
[Kubernetes SIG API Machinery](https://github.com/kubernetes/community/tree/master/sig-api-machinery).
-->
以下客户端库由 [Kubernetes SIG API Machinery](https://github.com/kubernetes/community/tree/master/sig-api-machinery) 正式维护。
以下客户端库由 [Kubernetes SIG API Machinery](https://github.com/kubernetes/community/tree/master/sig-api-machinery)
正式维护。

<!--
| Language | Client Library | Sample Programs |
Expand Down
55 changes: 26 additions & 29 deletions content/zh-cn/docs/reference/using-api/deprecation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ When APIs evolve, the old API is deprecated and eventually removed.
This page contains information you need to know when migrating from
deprecated API versions to newer and more stable API versions.
-->
随着 Kubernetes API 的演化,APIs 会周期性地被重组或升级。
APIs 演化时,老的 API 会被弃用并被最终删除。
随着 Kubernetes API 的演化,API 会周期性地被重组或升级。
API 演化时,老的 API 会被弃用并被最终删除。
本页面包含你在将已弃用 API 版本迁移到新的更稳定的 API 版本时需要了解的知识。

<!-- body -->
Expand Down Expand Up @@ -105,7 +105,7 @@ The **flowcontrol.apiserver.k8s.io/v1beta1** API version of FlowSchema and Prior
* All existing persisted objects are accessible via the new API
* No notable changes
-->
从 v1.26 版本开始不再提供 **flowcontrol.apiserver.k8s.io/v1beta1** API 版本的
从 v1.26 版本开始不再提供 **flowcontrol.apiserver.k8s.io/v1beta1** API 版本的
FlowSchema 和 PriorityLevelConfiguration。

* 迁移清单和 API 客户端使用 **flowcontrol.apiserver.k8s.io/v1beta3** API 版本,
Expand Down Expand Up @@ -148,7 +148,7 @@ The **batch/v1beta1** API version of CronJob is no longer served as of v1.25.

* 迁移清单和 API 客户端使用 **batch/v1** API 版本,此 API 从 v1.21 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

#### EndpointSlice {#endpointslice-v125}

Expand Down Expand Up @@ -218,15 +218,14 @@ The **events.k8s.io/v1beta1** API version of Event is no longer served as of v1.
<!--
The **autoscaling/v2beta1** API version of HorizontalPodAutoscaler is no longer served as of v1.25.
* Migrate manifests and API clients to use the **autoscaling/v2** API version, available since v1.23.
* All existing persisted objects are accessible via the new API
-->
从 v1.25 版本开始不再提供 **autoscaling/v2beta1** API 版本的
HorizontalPodAutoscaler。

* 迁移清单和 API 客户端使用 **autoscaling/v2** API 版本,此 API 从 v1.23 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问
* 所有的已保存的对象都可以通过新的 API 来访问

#### PodDisruptionBudget {#poddisruptionbudget-v125}

Expand All @@ -244,9 +243,9 @@ The **policy/v1beta1** API version of PodDisruptionBudget is no longer served as
* 所有的已保存的对象都可以通过新的 API 来访问;
* **policy/v1** 中需要额外注意的变更有:
*`policy/v1` 版本的 PodDisruptionBudget 中将 `spec.selector`
设置为空(`{}`)时会选择名字空间中的所有 Pods(在 `policy/v1beta1`
版本中,空的 `spec.selector` 不会选择任何 Pods)。如果 `spec.selector`
未设置,则在两个 API 版本下都不会选择任何 Pods
设置为空(`{}`)时会选择名字空间中的所有 Pod(在 `policy/v1beta1`
版本中,空的 `spec.selector` 不会选择任何 Pod)。如果 `spec.selector`
未设置,则在两个 API 版本下都不会选择任何 Pod

#### PodSecurityPolicy {#psp-v125}

Expand Down Expand Up @@ -278,7 +277,7 @@ RuntimeClass in the **node.k8s.io/v1beta1** API version is no longer served as o

* 迁移清单和 API 客户端使用 **node.k8s.io/v1** API 版本,此 API 从 v1.20 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

### v1.22

Expand All @@ -303,7 +302,7 @@ The **admissionregistration.k8s.io/v1beta1** API version of MutatingWebhookConfi
* All existing persisted objects are accessible via the new APIs
-->
* 迁移清单和 API 客户端使用 **admissionregistration.k8s.io/v1** API 版本,
此 API 从 v1.16 版本开始可用;
此 API 从 v1.16 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;

<!--
Expand Down Expand Up @@ -388,7 +387,7 @@ The **apiregistration.k8s.io/v1beta1** API version of APIService is no longer se
* 迁移清单和 API 客户端使用 **apiregistration.k8s.io/v1** API 版本,此 API 从
v1.10 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

#### TokenReview {#tokenreview-v122}

Expand All @@ -403,7 +402,7 @@ The **authentication.k8s.io/v1beta1** API version of TokenReview is no longer se
* 迁移清单和 API 客户端使用 **authentication.k8s.io/v1** API 版本,此 API 从
v1.6 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

#### SubjectAccessReview resources {#subjectaccessreview-resources-v122}

Expand All @@ -424,7 +423,6 @@ SelfSubjectAccessReview、SubjectAccessReview、SelfSubjectRulesReview 不在 v1
* `spec.group` 在 v1 版本中被更名为 `spec.groups`
(补丁 [#32709](https://github.com/kubernetes/kubernetes/issues/32709)


#### CertificateSigningRequest {#certificatesigningrequest-v122}

<!--
Expand Down Expand Up @@ -478,7 +476,7 @@ The **coordination.k8s.io/v1beta1** API version of Lease is no longer served as
* 迁移清单和 API 客户端使用 **coordination.k8s.io/v1** API 版本,此 API 从
v1.14 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

#### Ingress {#ingress-v122}

Expand All @@ -503,13 +501,13 @@ The **extensions/v1beta1** and **networking.k8s.io/v1beta1** API versions of Ing
* `pathType` is now required for each specified path. Options are `Prefix`, `Exact`, and `ImplementationSpecific`. To match the undefined `v1beta1` behavior, use `ImplementationSpecific`.
-->
* 值得注意的变更:
* `spec.backend` 字段被更名为 `spec.defaultBackend`
* 后端的 `serviceName` 字段被更名为 `service.name`
* 数值表示的后端 `servicePort` 字段被更名为 `service.port.number`
* 字符串表示的后端 `servicePort` 字段被更名为 `service.port.name`
* 对所有要指定的路径,`pathType` 都成为必需字段。
可选项为 `Prefix``Exact``ImplementationSpecific`
要匹配 `v1beta1` 版本中未定义路径类型时的行为,可使用 `ImplementationSpecific`
* `spec.backend` 字段被更名为 `spec.defaultBackend`
* 后端的 `serviceName` 字段被更名为 `service.name`
* 数值表示的后端 `servicePort` 字段被更名为 `service.port.number`
* 字符串表示的后端 `servicePort` 字段被更名为 `service.port.name`
* 对所有要指定的路径,`pathType` 都成为必需字段。
可选项为 `Prefix``Exact``ImplementationSpecific`
要匹配 `v1beta1` 版本中未定义路径类型时的行为,可使用 `ImplementationSpecific`

#### IngressClass {#ingressclass-v122}

Expand All @@ -525,8 +523,7 @@ The **networking.k8s.io/v1beta1** API version of IngressClass is no longer serve
* 迁移清单和 API 客户端使用 **networking.k8s.io/v1** API 版本,此 API 从
v1.19 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更

* 没有需要额外注意的变更。

<!--
#### RBAC resources {#rbac-resources-v122}
Expand All @@ -545,7 +542,7 @@ Role 和 RoleBinding 不在 v1.22 版本中继续提供。
* 迁移清单和 API 客户端使用 **rbac.authorization.k8s.io/v1** API 版本,此 API 从
v1.8 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

#### PriorityClass {#priorityclass-v122}

Expand All @@ -561,7 +558,7 @@ The **scheduling.k8s.io/v1beta1** API version of PriorityClass is no longer serv
* 迁移清单和 API 客户端使用 **scheduling.k8s.io/v1** API 版本,此 API 从
v1.14 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

<!--
#### Storage resources {#storage-resources-v122}
Expand All @@ -588,7 +585,7 @@ The **storage.k8s.io/v1beta1** API version of CSIDriver, CSINode, StorageClass,
* StorageClass 从 v1.6 版本开始在 **storage.k8s.io/v1** 中提供;
* VolumeAttachment 从 v1.13 版本开始在 **storage.k8s.io/v1** 中提供;
* 所有的已保存的对象都可以通过新的 API 来访问;
* 没有需要额外注意的变更
* 没有需要额外注意的变更

### v1.16

Expand All @@ -609,7 +606,7 @@ The **extensions/v1beta1** API version of NetworkPolicy is no longer served as o

* 迁移清单和 API 客户端使用 **networking.k8s.io/v1** API 版本,此 API 从
v1.8 版本开始可用;
* 所有的已保存的对象都可以通过新的 API 来访问
* 所有的已保存的对象都可以通过新的 API 来访问

#### DaemonSet {#daemonset-v116}

Expand Down Expand Up @@ -787,7 +784,7 @@ to automatically convert an existing object:
<!--
For example, to convert an older Deployment to `apps/v1`, you can run:
-->
例如,要将较老的 Deployment 版本转换为 `apps/v1` 版本,你可以运行
例如,要将较老的 Deployment 版本转换为 `apps/v1` 版本,你可以运行

`kubectl-convert -f ./my-deployment.yaml --output-version apps/v1`

Expand Down

0 comments on commit 0ed73f3

Please sign in to comment.