Skip to content

Commit 8d4d81e

Browse files
authored
[zh-cn]sync extend-resources/mutating-webhook-configuration-v1.md (#41121)
Signed-off-by: xin.li <[email protected]>
1 parent c018463 commit 8d4d81e

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

content/zh-cn/docs/reference/kubernetes-api/extend-resources/mutating-webhook-configuration-v1.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,115 @@ MutatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可接
234234

235235
failurePolicy 定义如何处理来自准入端点的无法识别的错误 - 允许的值是 Ignore 或 Fail。默认为 Fail。
236236

237+
<!--
238+
- **webhooks.matchConditions** ([]MatchCondition)
239+
240+
*Patch strategy: merge on key `name`*
241+
242+
*Map: unique values on key name will be kept during a merge*
243+
-->
244+
245+
- **webhooks.matchConditions** ([]MatchCondition)
246+
247+
**补丁策略:根据 `name` 键执行合并操作**
248+
249+
**映射:键 `name` 的唯一值将在合并过程中保留**
250+
251+
<!--
252+
MatchConditions is a list of conditions that must be met for a request to be sent to this webhook. Match conditions filter requests that have already been matched by the rules, namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests. There are a maximum of 64 match conditions allowed.
253+
-->
254+
255+
matchConditions 是将请求发送到此 webhook 之前必须满足的条件列表。
256+
匹配条件过滤已经被 rules、namespaceSelector、objectSelector 匹配的请求。
257+
matchConditions 取值为空列表时匹配所有请求。最多允许 64 个匹配条件。
258+
259+
<!--
260+
The exact matching logic is (in order):
261+
1. If ANY matchCondition evaluates to FALSE, the webhook is skipped.
262+
2. If ALL matchConditions evaluate to TRUE, the webhook is called.
263+
3. If any matchCondition evaluates to an error (but none are FALSE):
264+
- If failurePolicy=Fail, reject the request
265+
- If failurePolicy=Ignore, the error is ignored and the webhook is skipped
266+
-->
267+
268+
精确匹配逻辑是(按顺序):
269+
1. 如果任一 matchCondition 的计算结果为 FALSE,则跳过该 webhook。
270+
2. 如果所有 matchConditions 的计算结果为 TRUE,则调用该 webhook。
271+
3. 如果任一 matchCondition 的计算结果为错误(但都不是 FALSE):
272+
- 如果 failurePolicy=Fail,拒绝该请求;
273+
- 如果 failurePolicy=Ignore,忽略错误并跳过该 webhook。
274+
275+
<!--
276+
This is an alpha feature and managed by the AdmissionWebhookMatchConditions feature gate.
277+
278+
<a name="MatchCondition"></a>
279+
*MatchCondition represents a condition which must by fulfilled for a request to be sent to a webhook.*
280+
-->
281+
282+
这是一个 Alpha 功能特性,由 AdmissionWebhookMatchConditions 特性门控管理。
283+
284+
<a name="MatchCondition"></a>
285+
**MatchCondition 表示将请求发送到 Webhook 之前必须满足的条件。**
286+
287+
<!--
288+
- **webhooks.matchConditions.expression** (string), required
289+
290+
Expression represents the expression which will be evaluated by CEL. Must evaluate to bool. CEL expressions have access to the contents of the AdmissionRequest and Authorizer, organized into CEL variables:
291+
-->
292+
293+
- **webhooks.matchConditions.expression** (string), 必需
294+
295+
expression 表示将由 CEL 求值的表达式。求值结果必须是 bool 值。CEL 表达式可以访问
296+
以 CEL 变量的形式给出的 AdmissionRequest 和 Authorizer 的内容:
297+
298+
<!--
299+
'object' - The object from the incoming request. The value is null for DELETE requests. 'oldObject' - The existing object. The value is null for CREATE requests. 'request' - Attributes of the admission request(/pkg/apis/admission/types.go#AdmissionRequest). 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.
300+
-->
301+
302+
- 'object' - 来自传入请求的对象。对于 DELETE 请求,该值为 null。
303+
- 'oldObject' - 现有对象。对于 CREATE 请求,该值为 null。
304+
- 'request' - 准入请求的属性(/pkg/apis/admission/types.go#AdmissionRequest)。
305+
- 'authorizer' - CEL 授权者。可用于对请求的主体(用户或服务帐户)执行授权检查。
306+
307+
<!--
308+
See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
309+
-->
310+
311+
参阅: https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
312+
313+
<!--
314+
'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
315+
request resource.
316+
Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
317+
318+
Required.
319+
-->
320+
321+
- 'authorizer.requestResource' - CEL ResourceCheck 从"授权方"构建并配置请求资源。
322+
323+
CEL 文档: https://kubernetes.io/zh-cn/docs/reference/using-api/cel/
324+
325+
此字段为必需字段。
326+
327+
<!--
328+
- **webhooks.matchConditions.name** (string), required
329+
330+
Name is an identifier for this match condition, used for strategic merging of MatchConditions, as well as providing an identifier for logging purposes. A good name should be descriptive of the associated expression. Name must be a qualified name consisting of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')
331+
332+
Required.
333+
-->
334+
335+
- **webhooks.matchConditions.name** (string), 必需
336+
337+
name 是此匹配条件的标识符,用于 MatchConditions 的策略性合并,
338+
以及提供用于日志目的的标识符。一个好的 name 应该是对相关表达式的描述。
339+
name 必须是由字母数字字符 `-``_``.` 组成的限定名称,
340+
并且必须以字母、数字字符开头和结尾(例如 `MyName``my.name``123-abc`
341+
用于验证 name 的正则表达式是 `([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]`)。
342+
带有可选的 DNS 子域前缀和 `/`(例如 `example.com/MyName`
343+
344+
此字段为必需字段。
345+
237346
<!--
238347
- **webhooks.matchPolicy** (string)
239348
@@ -661,6 +770,15 @@ GET /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations
661770
662771
<a href="{{< ref "../common-parameters/common-parameters#resourceVersionMatch" >}}">resourceVersionMatch</a>
663772
773+
<!--
774+
- **sendInitialEvents** (*in query*): boolean
775+
776+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
777+
-->
778+
- **sendInitialEvents** (**查询参数**): boolean
779+
780+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
781+
664782
<!--
665783
- **timeoutSeconds** (*in query*): integer
666784
@@ -1131,6 +1249,15 @@ DELETE /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations
11311249
11321250
<a href="{{< ref "../common-parameters/common-parameters#resourceVersionMatch" >}}">resourceVersionMatch</a>
11331251
1252+
<!--
1253+
- **sendInitialEvents** (*in query*): boolean
1254+
1255+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
1256+
-->
1257+
- **sendInitialEvents** (**查询参数**): boolean
1258+
1259+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
1260+
11341261
<!--
11351262
- **timeoutSeconds** (*in query*): integer
11361263

0 commit comments

Comments
 (0)