Skip to content

Commit 0076f7d

Browse files
committed
[zh-cn]sync validating-webhook-configuration-v1.md
Signed-off-by: xin.li <[email protected]>
1 parent 04348f3 commit 0076f7d

File tree

1 file changed

+143
-25
lines changed

1 file changed

+143
-25
lines changed

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

Lines changed: 143 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,110 @@ ValidatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可
226226
227227
FailurePolicy defines how unrecognized errors from the admission endpoint are handled - allowed values are Ignore or Fail. Defaults to Fail.
228228
-->
229-
230229
- **webhooks.failurePolicy** (string)
231230

232231
failurePolicy 定义了如何处理来自准入端点的无法识别的错误 - 允许的值是 Ignore 或 Fail。默认为 Fail。
232+
233+
<!--
234+
- **webhooks.matchConditions** ([]MatchCondition)
235+
236+
*Patch strategy: merge on key `name`*
237+
238+
*Map: unique values on key name will be kept during a merge*
239+
-->
240+
- **webhooks.matchConditions** ([]MatchCondition)
241+
242+
**补丁策略:根据 `name` 键的取值合并**
243+
244+
**Map:name 键的唯一值将在合并期间保留**
245+
246+
<!--
247+
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.
248+
-->
249+
matchConditions 是将请求发送到此 webhook 之前必须满足的条件列表。
250+
匹配条件过滤已经被 rules、namespaceSelector、objectSelector 匹配的请求。
251+
matchConditions 取值为空列表时匹配所有请求。最多允许 64 个匹配条件。
252+
253+
<!--
254+
The exact matching logic is (in order):
255+
1. If ANY matchCondition evaluates to FALSE, the webhook is skipped.
256+
2. If ALL matchConditions evaluate to TRUE, the webhook is called.
257+
3. If any matchCondition evaluates to an error (but none are FALSE):
258+
- If failurePolicy=Fail, reject the request
259+
- If failurePolicy=Ignore, the error is ignored and the webhook is skipped
260+
-->
261+
精确匹配逻辑是(按顺序):
262+
1. 如果任一 matchCondition 的计算结果为 FALSE,则跳过该 webhook。
263+
2. 如果所有 matchConditions 的计算结果为 TRUE,则调用该 webhook。
264+
3. 如果任一 matchCondition 的计算结果为错误(但都不是 FALSE):
265+
- 如果 failurePolicy=Fail,拒绝该请求;
266+
- 如果 failurePolicy=Ignore,忽略错误并跳过该 webhook。
267+
268+
<!--
269+
This is an alpha feature and managed by the AdmissionWebhookMatchConditions feature gate.
270+
271+
<a name="MatchCondition"></a>
272+
*MatchCondition represents a condition which must by fulfilled for a request to be sent to a webhook.*
273+
-->
274+
这是一个 Alpha 功能特性,由 AdmissionWebhookMatchConditions 特性门控管理。
275+
276+
<a name="MatchCondition"></a>
277+
**MatchCondition 表示将请求发送到 Webhook 之前必须满足的条件。**
278+
279+
<!--
280+
- **webhooks.matchConditions.expression** (string), required
281+
282+
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:
283+
-->
284+
- **webhooks.matchConditions.expression** (string), 必需
285+
286+
expression 表示将由 CEL 求值的表达式。求值结果必须是 bool 值。CEL 表达式可以访问
287+
以 CEL 变量的形式给出的 AdmissionRequest 和 Authorizer 的内容:
288+
289+
<!--
290+
'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.
291+
-->
292+
- 'object' - 来自传入请求的对象。对于 DELETE 请求,该值为 null。
293+
- 'oldObject' - 现有对象。对于 CREATE 请求,该值为 null。
294+
- 'request' - 准入请求的属性(/pkg/apis/admission/types.go#AdmissionRequest)。
295+
- 'authorizer' - CEL 授权者。可用于对请求的主体(用户或服务帐户)执行授权检查。
296+
297+
<!--
298+
See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
299+
-->
300+
301+
参阅:https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
302+
303+
<!--
304+
'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
305+
request resource.
306+
Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
307+
308+
Required.
309+
-->
310+
- 'authorizer.requestResource' - CEL ResourceCheck 从"授权方"构建并配置请求资源。
311+
312+
CEL 文档:https://kubernetes.io/zh-cn/docs/reference/using-api/cel/
313+
314+
此字段为必需字段。
315+
316+
<!--
317+
- **webhooks.matchConditions.name** (string), required
318+
319+
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')
320+
321+
Required.
322+
-->
323+
- **webhooks.matchConditions.name** (string), 必需
324+
325+
name 是此匹配条件的标识符,用于 MatchConditions 的策略性合并,
326+
以及提供用于日志目的的标识符。一个好的 name 应该是对相关表达式的描述。
327+
name 必须是由字母数字字符 `-``_``.` 组成的限定名称,
328+
并且必须以字母、数字字符开头和结尾(例如 `MyName``my.name``123-abc`
329+
用于验证 name 的正则表达式是 `([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]`)。
330+
带有可选的 DNS 子域前缀和 `/`(例如 `example.com/MyName`
331+
332+
此字段为必需字段。
233333

234334
<!--
235335
- **webhooks.matchPolicy** (string)
@@ -274,16 +374,16 @@ ValidatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可
274374
你可以按如下方式设置 selector :
275375
```
276376
"namespaceSelector": {
277-
"matchExpressions": [
278-
{
279-
"key": "runlevel",
280-
"operator": "NotIn",
281-
"values": [
282-
"0",
283-
"1"
284-
]
285-
}
286-
]
377+
"matchExpressions": [
378+
{
379+
"key": "runlevel",
380+
"operator": "NotIn",
381+
"values": [
382+
"0",
383+
"1"
384+
]
385+
}
386+
]
287387
}
288388
```
289389
<!--
@@ -293,16 +393,16 @@ ValidatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可
293393
你可以按如下方式设置 selector:
294394
```
295395
"namespaceSelector": {
296-
"matchExpressions": [
297-
{
298-
"key": "environment",
299-
"operator": "In",
300-
"values": [
301-
"prod",
302-
"staging"
303-
]
304-
}
305-
]
396+
"matchExpressions": [
397+
{
398+
"key": "environment",
399+
"operator": "In",
400+
"values": [
401+
"prod",
402+
"staging"
403+
]
404+
}
405+
]
306406
}
307407
```
308408
<!--
@@ -415,10 +515,10 @@ ValidatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可
415515
416516
resources 是此规则适用的资源列表。
417517
418-
'pods' 表示 pods,'pods/log' 表示 pods 的日志子资源。'*' 表示所有资源,但不是子资源。
419-
'pods/*' 表示 pods 的所有子资源,
420-
'*/scale' 表示所有 scale 子资源,
421-
'*/*' 表示所有资源及其子资源。
518+
- 'pods' 表示 pods,'pods/log' 表示 pods 的日志子资源。'*' 表示所有资源,但不是子资源。
519+
- 'pods/*' 表示 pods 的所有子资源,
520+
- '*/scale' 表示所有 scale 子资源,
521+
- '*/*' 表示所有资源及其子资源。
422522
423523
如果存在通配符,则验证规则将确保资源不会相互重叠。
424524
@@ -628,6 +728,15 @@ GET /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations
628728
629729
<a href="{{< ref "../common-parameters/common-parameters#resourceVersionMatch" >}}">resourceVersionMatch</a>
630730
731+
<!--
732+
- **sendInitialEvents** (*in query*): boolean
733+
734+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
735+
-->
736+
- **sendInitialEvents** (**查询参数**): boolean
737+
738+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
739+
631740
<!--
632741
- **timeoutSeconds** (*in query*): integer
633742
@@ -1098,6 +1207,15 @@ DELETE /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations
10981207
10991208
<a href="{{< ref "../common-parameters/common-parameters#resourceVersionMatch" >}}">resourceVersionMatch</a>
11001209
1210+
<!--
1211+
- **sendInitialEvents** (*in query*): boolean
1212+
1213+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
1214+
-->
1215+
- **sendInitialEvents** (**查询参数**): boolean
1216+
1217+
<a href="{{< ref "../common-parameters/common-parameters#sendInitialEvents" >}}">sendInitialEvents</a>
1218+
11011219
<!--
11021220
- **timeoutSeconds** (*in query*): integer
11031221

0 commit comments

Comments
 (0)