Skip to content

Commit 084fc01

Browse files
committed
[zh] Resync VAP reference page
1 parent 9557e72 commit 084fc01

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

content/zh-cn/docs/reference/access-authn-authz/validating-admission-policy.md

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ otherwise the failures are ignored.
199199
否则这些失败将被忽略。
200200

201201
<!--
202-
See [Audit Annotations: validation failures](/docs/reference/labels-annotations-taints/audit-annotations/#validation-policy-admission-k8s-io-validation-failure) for more details about the validation failure audit annotation.
202+
See [Audit Annotations: validation failures](/docs/reference/labels-annotations-taints/audit-annotations/#validation-policy-admission-k8s-io-validation-failure)
203+
for more details about the validation failure audit annotation.
203204
-->
204205
有关验证失败审计注解的详细信息,
205206
请参见[审计注解:验证失败](/zh-cn/docs/reference/labels-annotations-taints/audit-annotations/#validation-policy-admission-k8s-io-validation_failure)。
@@ -274,6 +275,7 @@ The parameter resource could be as following:
274275

275276
<!--
276277
This policy parameter resource limits deployments to a max of 3 replicas.
278+
277279
An admission policy may have multiple bindings. To bind all other environments
278280
to have a maxReplicas limit of 100, create another ValidatingAdmissionPolicyBinding:
279281
-->
@@ -321,29 +323,6 @@ parameters.
321323
多个绑定之间可以在匹配条件存在重叠。系统针对匹配的绑定参数所有组合来评估策略。如果多个绑定与其匹配,
322324
或者同一个绑定与多个参数匹配,则策略甚至可以被多次评估。
323325

324-
<!--
325-
Bindings can have overlapping match criteria. The policy is evaluated for each matching binding.
326-
In the above example, the "nontest" policy binding could instead have been defined as a global policy:
327-
-->
328-
绑定可以包含相互重叠的匹配条件。策略会针对每个匹配的绑定进行计算。
329-
在上面的例子中,`nontest` 策略绑定可以被定义为一个全局策略:
330-
331-
```yaml
332-
apiVersion: admissionregistration.k8s.io/v1alpha1
333-
kind: ValidatingAdmissionPolicyBinding
334-
metadata:
335-
name: "replicalimit-binding-global"
336-
spec:
337-
policyName: "replicalimit-policy.example.com"
338-
validationActions: [Deny]
339-
params: "replica-limit-clusterwide.example.com"
340-
matchResources:
341-
namespaceSelector:
342-
matchExpressions:
343-
- key: environment
344-
operator: Exists
345-
```
346-
347326
<!--
348327
The params object representing a parameter resource will not be set if a parameter resource has
349328
not been bound, so for policies requiring a parameter resource, it can be useful to add a check to
@@ -460,7 +439,7 @@ admitted will be used.
460439
否则,当 `namespace` 为空且 `paramKind` 为命名空间作用域的资源时,使用被准入请求中指定的 `namespace`。
461440
462441
<!--
463-
#### Authorization Check
442+
#### Authorization checks {#authorization-check}
464443
465444
We introduced the authorization check for parameter resources.
466445
User is expected to have `read` access to the resources referenced by `paramKind` in
@@ -524,19 +503,28 @@ CEL 表达式可以访问按 CEL 变量来组织的 Admission 请求/响应的
524503
- 'request' - Attributes of the [admission request](/docs/reference/config-api/apiserver-admission.v1/#admission-k8s-io-v1-AdmissionRequest).
525504
- 'params' - Parameter resource referred to by the policy binding being evaluated. The value is
526505
null if `ParamKind` is not specified.
506+
- `namespaceObject` - The namespace, as a Kubernetes resource, that the incoming object belongs to.
507+
The value is null if the incoming object is cluster-scoped.
508+
-->
509+
- 'object' - 来自传入请求的对象。对于 DELETE 请求,该值为 null。
510+
- 'oldObject' - 现有对象。对于 CREATE 请求,该值为 null。
511+
- 'request' - [准入请求](/zh-cn/docs/reference/config-api/apiserver-admission.v1/#admission-k8s-io-v1-AdmissionRequest)的属性。
512+
- 'params' - 被计算的策略绑定引用的参数资源。如果未设置 `paramKind`,该值为 null。
513+
- `namespaceObject` - 作为 Kubernetes 资源的、传输对象所在的名字空间。
514+
如果传入对象是集群作用域的,则此值为 null。
515+
516+
<!--
527517
- `authorizer` - A CEL Authorizer. May be used to perform authorization checks for the principal
528518
(authenticated user) of the request. See
519+
[AuthzSelectors](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#AuthzSelectors) and
529520
[Authz](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz) in the Kubernetes CEL library
530521
documentation for more details.
531522
- `authorizer.requestResource` - A shortcut for an authorization check configured with the request
532523
resource (group, resource, (subresource), namespace, name).
533524
-->
534-
- 'object' - 来自传入请求的对象。对于 DELETE 请求,该值为 null。
535-
- 'oldObject' - 现有对象。对于 CREATE 请求,该值为 null。
536-
- 'request' - [准入请求](/zh-cn/docs/reference/config-api/apiserver-admission.v1/#admission-k8s-io-v1-AdmissionRequest)的属性。
537-
- 'params' - 被计算的策略绑定引用的参数资源。如果未设置 `paramKind`,该值为 null。
538525
- `authorizer` - 一个 CEL 鉴权组件。可以用来为请求的主体(经过身份验证的用户)执行鉴权检查。
539-
更多细节可以参考 Kubernetes CEL 库的文档中的 [Authz](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz)。
526+
更多细节可以参考 [AuthzSelectors](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#AuthzSelectors)
527+
和 Kubernetes CEL 库的文档中的 [Authz](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz)。
540528
- `authorizer.requestResource` - 针对请求资源(组、资源、(子资源)、命名空间、名称)所配置的鉴权检查的快捷方式。
541529
542530
<!--
@@ -565,9 +553,28 @@ Concatenation on arrays with x-kubernetes-list-type use the semantics of the lis
565553
566554
<!--
567555
#### Validation expression examples
556+
557+
| Expression | Purpose |
558+
|----------------------------------------------------------------------------------------------| ------------ |
559+
| `object.minReplicas <= object.replicas && object.replicas <= object.maxReplicas` | Validate that the three fields defining replicas are ordered appropriately |
560+
| `'Available' in object.stateCounts` | Validate that an entry with the 'Available' key exists in a map |
561+
| `(size(object.list1) == 0) != (size(object.list2) == 0)` | Validate that one of two lists is non-empty, but not both |
562+
| <code>!('MY_KEY' in object.map1) &#124;&#124; object['MY_KEY'].matches('^[a-zA-Z]*$')</code> | Validate the value of a map for a specific key, if it is in the map |
563+
| `object.envars.filter(e, e.name == 'MY_ENV').all(e, e.value.matches('^[a-zA-Z]*$')` | Validate the 'value' field of a listMap entry where key field 'name' is 'MY_ENV' |
564+
| `has(object.expired) && object.created + object.ttl < object.expired` | Validate that 'expired' date is after a 'create' date plus a 'ttl' duration |
565+
| `object.health.startsWith('ok')` | Validate a 'health' string field has the prefix 'ok' |
566+
| `object.widgets.exists(w, w.key == 'x' && w.foo < 10)` | Validate that the 'foo' property of a listMap item with a key 'x' is less than 10 |
567+
| `type(object) == string ? object == '100%' : object == 1000` | Validate an int-or-string field for both the int and string cases |
568+
| `object.metadata.name.startsWith(object.prefix)` | Validate that an object's name has the prefix of another field value |
569+
| `object.set1.all(e, !(e in object.set2))` | Validate that two listSets are disjoint |
570+
| `size(object.names) == size(object.details) && object.names.all(n, n in object.details)` | Validate the 'details' map is keyed by the items in the 'names' listSet |
571+
| `size(object.clusters.filter(c, c.name == object.primary)) == 1` | Validate that the 'primary' property has one and only one occurrence in the 'clusters' listMap |
572+
573+
568574
-->
569575
#### 检查表达式示例
570576
577+
571578
| 表达式 | 目的 |
572579
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
573580
| `object.minReplicas <= object.replicas && object.replicas <= object.maxReplicas` | 检查定义副本的三个字段是否大小关系正确 |

0 commit comments

Comments
 (0)