@@ -115,24 +115,32 @@ The following is an example of a ValidatingAdmissionPolicy.
115115
116116以下是一个 ValidatingAdmissionPolicy 的示例:
117117
118- {{% codenew language="yaml" file="validatingadmissionpolicy/basic-example-policy.yaml" %}}
118+ {{% code_sample language="yaml" file="validatingadmissionpolicy/basic-example-policy.yaml" %}}
119119
120120<!--
121121`spec.validations` contains CEL expressions which use the [Common Expression Language (CEL)](https://github.com/google/cel-spec)
122122to validate the request. If an expression evaluates to false, the validation check is enforced
123123according to the `spec.failurePolicy` field.
124-
125- To configure a validating admission policy for use in a cluster, a binding is required.
126- The following is an example of a ValidatingAdmissionPolicyBinding.:
127124-->
128125` spec.validations ` 包含使用[ 通用表达式语言 (CEL)] ( https://github.com/google/cel-spec )
129126来验证请求的 CEL 表达式。
130127如果表达式的计算结果为 false,则根据 ` spec.failurePolicy ` 字段强制执行验证检查处理。
131128
129+ {{< note >}}
130+ <!--
131+ You can quickly test CEL expressions in [CEL Playground](https://playcel.undistro.io).
132+ -->
133+ 你可以在 [ CEL Playground] ( https://playcel.undistro.io ) 中快速验证 CEL 表达式。
134+ {{< /note >}}
135+
136+ <!--
137+ To configure a validating admission policy for use in a cluster, a binding is required.
138+ The following is an example of a ValidatingAdmissionPolicyBinding:
139+ -->
132140要配置一个在某集群中使用的验证准入策略,需要一个绑定。
133141以下是一个 ValidatingAdmissionPolicyBinding 的示例:
134142
135- {{% codenew language="yaml" file="validatingadmissionpolicy/basic-example-binding.yaml" %}}
143+ {{% code_sample language="yaml" file="validatingadmissionpolicy/basic-example-binding.yaml" %}}
136144
137145<!--
138146When trying to create a deployment with replicas set not satisfying the validation expression, an
@@ -226,7 +234,7 @@ with parameter configuration.
226234
227235如果需要参数配置,下面是一个带有参数配置的 ValidatingAdmissionPolicy 的例子:
228236
229- {{% codenew language="yaml" file="validatingadmissionpolicy/policy-with-param.yaml" %}}
237+ {{% code_sample language="yaml" file="validatingadmissionpolicy/policy-with-param.yaml" %}}
230238
231239<!--
232240The `spec.paramKind` field of the ValidatingAdmissionPolicy specifies the kind of resources used
@@ -261,7 +269,7 @@ every resource request that matches the binding:
261269要配置一个在某集群中使用的验证准入策略,需要创建绑定和参数资源。
262270以下是 ValidatingAdmissionPolicyBinding **集群范围**参数的示例 - 相同的参数将用于验证与绑定匹配的每个资源请求:
263271
264- {{% codenew language="yaml" file="validatingadmissionpolicy/binding-with-param.yaml" %}}
272+ {{% code_sample language="yaml" file="validatingadmissionpolicy/binding-with-param.yaml" %}}
265273
266274<!--
267275Notice this binding applies a parameter to the policy for all resources which
@@ -274,7 +282,7 @@ The parameter resource could be as following:
274282-->
275283参数资源可以如下:
276284
277- {{% codenew language="yaml" file="validatingadmissionpolicy/replicalimit-param.yaml" %}}
285+ {{% code_sample language="yaml" file="validatingadmissionpolicy/replicalimit-param.yaml" %}}
278286
279287<!--
280288This policy parameter resource limits deployments to a max of 3 replicas.
@@ -285,7 +293,7 @@ to have a maxReplicas limit of 100, create another ValidatingAdmissionPolicyBind
285293一个准入策略可以有多个绑定。
286294要绑定所有的其他环境,限制 maxReplicas 为 100,请创建另一个 ValidatingAdmissionPolicyBinding:
287295
288- {{% codenew language="yaml" file="validatingadmissionpolicy/binding-with-param-prod.yaml" %}}
296+ {{% code_sample language="yaml" file="validatingadmissionpolicy/binding-with-param-prod.yaml" %}}
289297
290298<!--
291299Notice this binding applies a different parameter to resources which
@@ -298,7 +306,7 @@ And have a parameter resource:
298306-->
299307并有一个参数资源:
300308
301- {{% codenew language="yaml" file="validatingadmissionpolicy/replicalimit-param-prod.yaml" %}}
309+ {{% code_sample language="yaml" file="validatingadmissionpolicy/replicalimit-param-prod.yaml" %}}
302310
303311<!--
304312For each admission request, the API server evaluates CEL expressions of each
@@ -415,7 +423,7 @@ searches for parameters in that namespace.
415423
416424作为 ValidatingAdmissionPolicy 及其 ValidatingAdmissionPolicyBinding 的作者,
417425你可以选择指定其作用于集群范围还是某个命名空间。如果你为绑定的 `paramRef` 指定 `namespace`,
418- 则控制平面仅在该名字空间中搜索参数 。
426+ 则控制平面仅在该命名空间中搜索参数 。
419427
420428<!--
421429However, if `namespace` is not specified in the ValidatingAdmissionPolicyBinding, the
@@ -504,7 +512,7 @@ Note that the `failurePolicy` is defined inside `ValidatingAdmissionPolicy`:
504512
505513请注意,`failurePolicy` 是在 `ValidatingAdmissionPolicy` 中定义的:
506514
507- {{% codenew language="yaml" file="validatingadmissionpolicy/failure-policy-ignore.yaml" %}}
515+ {{% code_sample language="yaml" file="validatingadmissionpolicy/failure-policy-ignore.yaml" %}}
508516
509517<!--
510518### Validation Expression
@@ -662,7 +670,7 @@ Here is an example illustrating a few different uses for match conditions:
662670-->
663671以下示例说明了匹配条件的几个不同用法:
664672
665- {{% codenew file="access/validating-admission-policy-match-conditions.yaml" %}}
673+ {{% code_sample file="access/validating-admission-policy-match-conditions.yaml" %}}
666674
667675<!--
668676Match conditions have access to the same CEL variables as validation expressions.
@@ -698,7 +706,7 @@ For example, here is an admission policy with an audit annotation:
698706
699707例如,以下是带有审计注解的准入策略:
700708
701- {{% codenew file="access/validating-admission-policy-audit-annotation.yaml" %}}
709+ {{% code_sample file="access/validating-admission-policy-audit-annotation.yaml" %}}
702710
703711<!--
704712When an API request is validated with this admission policy, the resulting audit event will look like:
@@ -772,7 +780,7 @@ we can have the following validation:
772780
773781例如,为了在策略引用参数时更好地告知用户拒绝原因,我们可以有以下验证:
774782
775- {{% codenew file="access/deployment-replicas-policy.yaml" %}}
783+ {{% code_sample file="access/deployment-replicas-policy.yaml" %}}
776784
777785<!--
778786After creating a params object that limits the replicas to 3 and setting up the binding,
@@ -825,7 +833,7 @@ For example, given the following policy definition:
825833
826834例如,给定以下策略定义:
827835
828- {{% codenew language="yaml" file="validatingadmissionpolicy/typechecking.yaml" %}}
836+ {{% code_sample language="yaml" file="validatingadmissionpolicy/typechecking.yaml" %}}
829837
830838<!--
831839The status will yield the following information:
@@ -850,7 +858,7 @@ For example, the following policy definition
850858如果在 ` spec.matchConstraints ` 中匹配了多个资源,则所有匹配的资源都将进行检查。
851859例如,以下策略定义:
852860
853- {{% codenew language="yaml" file="validatingadmissionpolicy/typechecking-multiple-match.yaml" %}}
861+ {{% code_sample language="yaml" file="validatingadmissionpolicy/typechecking-multiple-match.yaml" %}}
854862
855863<!--
856864will have multiple types and type checking result of each type in the warning message.
@@ -932,7 +940,7 @@ The following is a more complex example of enforcing that image repo names match
932940
933941以下是强制镜像仓库名称与其命名空间中定义的环境相匹配的一个较复杂示例。
934942
935- {{< codenew file="access/image-matches-namespace-environment.policy.yaml" >}}
943+ {{< code_sample file="access/image-matches-namespace-environment.policy.yaml" >}}
936944
937945<!--
938946With the policy bound to the namespace `default`, which is labeled `environment : prod`,
0 commit comments