Skip to content

Commit ac06619

Browse files
committed
[zh-cn] sync blog:2023-08-28-a-new-alpha-mechanism-for-safer-cluster-upgrades.md
Signed-off-by: xin.li <[email protected]>
1 parent 37fa3ce commit ac06619

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.28:用于改进集群安全升级的新(Alpha)机制"
4+
date: 2023-08-28
5+
slug: kubernetes-1-28-feature-mixed-version-proxy-alpha
6+
---
7+
8+
<!--
9+
layout: blog
10+
title: "Kubernetes 1.28: A New (alpha) Mechanism For Safer Cluster Upgrades"
11+
date: 2023-08-28
12+
slug: kubernetes-1-28-feature-mixed-version-proxy-alpha
13+
-->
14+
15+
<!--
16+
**Author:** Richa Banker (Google)
17+
-->
18+
**作者:** Richa Banker (Google)
19+
20+
**译者:** Xin Li (DaoCloud)
21+
22+
<!--
23+
This blog describes the _mixed version proxy_, a new alpha feature in Kubernetes 1.28. The
24+
mixed version proxy enables an HTTP request for a resource to be served by the correct API server
25+
in cases where there are multiple API servers at varied versions in a cluster. For example,
26+
this is useful during a cluster upgrade, or when you're rolling out the runtime configuration of
27+
the cluster's control plane.
28+
-->
29+
本博客介绍了**混合版本代理(Mixed Version Proxy)**,这是 Kubernetes 1.28 中的一个新的
30+
Alpha 级别特性。当集群中存在多个不同版本的 API 服务器时,混合版本代理使对资源的 HTTP 请求能够被正确的
31+
API 服务器处理。例如,在集群升级期间或当发布集群控制平面的运行时配置时此特性非常有用。
32+
33+
<!--
34+
## What problem does this solve?
35+
When a cluster undergoes an upgrade, the kube-apiservers existing at different
36+
versions in that scenario can serve different sets (groups, versions, resources)
37+
of built-in resources. A resource request made in this scenario may be served by
38+
any of the available apiservers, potentially resulting in the request ending up
39+
at an apiserver that may not be aware of the requested resource; consequently it
40+
being served a 404 not found error which is incorrect. Furthermore, incorrect serving
41+
of the 404 errors can lead to serious consequences such as namespace deletion being
42+
blocked incorrectly or objects being garbage collected mistakenly.
43+
-->
44+
## 这解决了什么问题?
45+
46+
当集群进行升级时,集群中不同版本的 kube-apiserver 为不同的内置资源集(组、版本、资源)提供服务。
47+
在这种情况下资源请求如果由任一可用的 apiserver 提供服务,请求可能会到达无法解析此请求资源的
48+
apiserver 中;因此,它会收到 404("Not Found")的响应报错,这是不正确的。
49+
此外,返回 404 的错误服务可能会导致严重的后果,例如命名空间的删除被错误阻止或资源对象被错误地回收。
50+
51+
<!--
52+
## How do we solve the problem?
53+
54+
{{< figure src="/images/blog/2023-08-28-a-new-alpha-mechanism-for-safer-cluster-upgrades/mvp-flow-diagram.svg" class="diagram-large" >}}
55+
-->
56+
## 如何解决此问题?
57+
58+
{{< figure src="/images/blog/2023-08-28-a-new-alpha-mechanism-for-safer-cluster-upgrades/mvp-flow-diagram.svg" class="diagram-large" >}}
59+
60+
<!--
61+
The new feature “Mixed Version Proxy” provides the kube-apiserver with the capability to proxy a request to a peer kube-apiserver which is aware of the requested resource and hence can serve the request. To do this, a new filter has been added to the handler chain in the API server's aggregation layer.
62+
-->
63+
"混合版本代理"新特性为 kube-apiserver 提供了将请求代理到对等的、
64+
能够感知所请求的资源并因此能够服务请求的 kube-apiserver。
65+
为此,一个全新的过滤器已被添加到 API
66+
67+
<!--
68+
1. The new filter in the handler chain checks if the request is for a group/version/resource
69+
that the apiserver doesn't know about (using the existing
70+
[StorageVersion API](https://github.com/kubernetes/kubernetes/blob/release-1.28/pkg/apis/apiserverinternal/types.go#L25-L37)).
71+
If so, it proxies the request to one of the apiservers that is listed in the ServerStorageVersion object.
72+
If the identified peer apiserver fails to respond (due to reasons like network connectivity,
73+
race between the request being received and the controller registering the apiserver-resource info
74+
in ServerStorageVersion object), then error 503("Service Unavailable") is served.
75+
2. To prevent indefinite proxying of the request, a (new for v1.28) HTTP header
76+
`X-Kubernetes-APIServer-Rerouted: true` is added to the original request once
77+
it is determined that the request cannot be served by the original API server.
78+
Setting that to true marks that the original API server couldn't handle the request
79+
and it should therefore be proxied. If a destination peer API server sees this header,
80+
it never proxies the request further.
81+
3. To set the network location of a kube-apiserver that peers will use to proxy requests,
82+
the value passed in `--advertise-address` or (when `--advertise-address` is unspecified)
83+
the `--bind-address` flag is used. For users with network configurations that would not
84+
allow communication between peer kube-apiservers using the addresses specified in these flags,
85+
there is an option to pass in the correct peer address as `--peer-advertise-ip` and
86+
`--peer-advertise-port` flags that are introduced in this feature.
87+
-->
88+
1. 处理程序链中的新过滤器检查请求是否为 apiserver 无法解析的 API 组/版本/资源(使用现有的
89+
[StorageVersion API](https://github.com/kubernetes/kubernetes/blob/release-1.28/pkg/apis/apiserverinternal/types.go#L25-L37))。
90+
如果是,它会将请求代理到 ServerStorageVersion 对象中列出的 apiserver 之一。
91+
如果所选的对等 apiserver 无法响应(由于网络连接、收到的请求与在 ServerStorageVersion
92+
对象中注册 apiserver-resource 信息的控制器之间的竞争等原因),则会出现 503("Service Unavailable")错误响应。
93+
2. 为了防止无限期地代理请求,一旦最初的 API 服务器确定无法处理该请求,就会在原始请求中添加一个
94+
(v1.28 新增)HTTP 请求头 `X-Kubernetes-APIServer-Rerouted: true`。将其设置为 true 意味着原始
95+
API 服务器无法处理该请求,需要对其进行代理。如果目标侧对等 API 服务器看到此标头,则不会对该请求做进一步的代理操作。
96+
3. 要设置 kube-apiserver 的网络位置,以供对等服务器来代理请求,将使用 `--advertise-address`
97+
或(当未指定`--advertise-address`时)`--bind-address` 标志所设置的值。
98+
如果网络配置中不允许用户在对等 kube-apiserver 之间使用这些标志中指定的地址进行通信,
99+
可以选择将正确的对等地址配置在此特性引入的 `--peer-advertise-ip``--peer-advertise-port`
100+
参数中。
101+
102+
<!--
103+
## How do I enable this feature?
104+
Following are the required steps to enable the feature:
105+
-->
106+
## 如何启用此特性?
107+
108+
以下是启用此特性的步骤:
109+
110+
<!--
111+
* Download the [latest Kubernetes project](/releases/download/) (version `v1.28.0` or later)
112+
* Switch on the feature gate with the command line flag `--feature-gates=UnknownVersionInteroperabilityProxy=true`
113+
on the kube-apiservers
114+
* Pass the CA bundle that will be used by source kube-apiserver to authenticate
115+
destination kube-apiserver's serving certs using the flag `--peer-ca-file`
116+
on the kube-apiservers. Note: this is a required flag for this feature to work.
117+
There is no default value enabled for this flag.
118+
* Pass the correct ip and port of the local kube-apiserver that will be used by
119+
peers to connect to this kube-apiserver while proxying a request.
120+
Use the flags `--peer-advertise-ip` and `peer-advertise-port` to the kube-apiservers
121+
upon startup. If unset, the value passed to either `--advertise-address` or `--bind-address`
122+
is used. If those too, are unset, the host's default interface will be used.
123+
-->
124+
* 下载[Kubernetes 项目的最新版本](/zh-cn/releases/download/)(版本 `v1.28.0` 或更高版本)
125+
* 在 kube-apiserver 上使用命令行标志 `--feature-gates=UnknownVersionInteroperabilityProxy=true`
126+
打开特性门控
127+
* 使用 kube-apiserver 的 `--peer-ca-file` 参数为源 kube-apiserver 提供 CA 证书,
128+
用以验证目标 kube-apiserver 的服务证书。注意:这是此功能正常工作所必需的参数。
129+
此参数没有默认值。
130+
* 为本地 kube-apiserver 设置正确的 IP 和端口,在代理请求时,对等方将使用该 IP 和端口连接到此
131+
`--peer-advertise-port` 命令行参数来配置 kube-apiserver。
132+
`--peer-advertise-port` 命令行参数。
133+
如果未设置这两个参数,则默认使用 `--advertise-address``--bind-address` 命令行参数的值。
134+
如果这些也未设置,则将使用主机的默认接口。
135+
136+
<!--
137+
## What’s missing?
138+
Currently we only proxy resource requests to a peer kube-apiserver when its determined to do so.
139+
Next we need to address how to work discovery requests in such scenarios. Right now we are planning
140+
to have the following capabilities for beta
141+
-->
142+
## 少了什么东西?
143+
144+
目前,我们仅在确定时将资源请求代理到对等 kube-apiserver。
145+
接下来我们需要解决如何在这种情况下处理发现请求。
146+
目前我们计划在测试版中提供以下特性:
147+
148+
<!--
149+
* Merged discovery across all kube-apiservers
150+
* Use an egress dialer for network connections made to peer kube-apiservers
151+
-->
152+
* 合并所有 kube-apiserver 的发现数据
153+
* 使用出口拨号器(egress dialer)与对等 kube-apiserver 进行网络连接
154+
155+
<!--
156+
## How can I learn more?
157+
158+
- Read the [Mixed Version Proxy documentation](/docs/concepts/architecture/mixed-version-proxy)
159+
- Read [KEP-4020: Unknown Version Interoperability Proxy](https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/4020-unknown-version-interoperability-proxy)
160+
-->
161+
## 如何进一步了解?
162+
163+
- 阅读[混合版本代理文档](/zh-cn/docs/concepts/architecture/mixed-version-proxy)
164+
- 阅读 [KEP-4020:未知版本互操作代理](https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/4020-unknown-version-interoperability-proxy)
165+
166+
<!--
167+
## How can I get involved?
168+
Reach us on [Slack](https://slack.k8s.io/): [#sig-api-machinery](https://kubernetes.slack.com/messages/sig-api-machinery), or through the [mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-api-machinery).
169+
170+
Huge thanks to the contributors that have helped in the design, implementation, and review of this feature: Daniel Smith, Han Kang, Joe Betz, Jordan Liggit, Antonio Ojea, David Eads and Ben Luddy!
171+
-->
172+
## 如何参与其中?
173+
174+
通过 [Slack](https://slack.k8s.io/)[#sig-api-machinery](https://kubernetes.slack.com/messages/sig-api-machinery)
175+
[邮件列表](https://groups.google.com/forum/#!forum/kubernetes-sig-api-machinery)
176+
联系我们。
177+
178+
非常感谢帮助设计、实施和评审此特性的贡献者:
179+
Daniel Smith、Han Kang、Joe Betz、Jordan Liggit、Antonio Ojea、David Eads 和 Ben Luddy!

0 commit comments

Comments
 (0)