Skip to content

Commit c1732d6

Browse files
authored
Merge pull request kubernetes#49688 from my-git9/np-11076
[zh-cn]sync rbac validating-admission-policy
2 parents c5bb0a6 + bef6abc commit c1732d6

File tree

4 files changed

+45
-55
lines changed

4 files changed

+45
-55
lines changed

Diff for: content/zh-cn/docs/reference/access-authn-authz/rbac.md

+2-54
Original file line numberDiff line numberDiff line change
@@ -151,30 +151,7 @@ Here's an example Role in the "default" namespace that can be used to grant read
151151
下面是一个位于 "default" 名字空间的 Role 的示例,可用来授予对
152152
{{< glossary_tooltip text="Pod" term_id="pod" >}} 的读访问权限:
153153

154-
<!--
155-
```yaml
156-
apiVersion: rbac.authorization.k8s.io/v1
157-
kind: Role
158-
metadata:
159-
namespace: default
160-
name: pod-reader
161-
rules:
162-
- apiGroups: [""] # "" indicates the core API group
163-
resources: ["pods"]
164-
verbs: ["get", "watch", "list"]
165-
```
166-
-->
167-
```yaml
168-
apiVersion: rbac.authorization.k8s.io/v1
169-
kind: Role
170-
metadata:
171-
namespace: default
172-
name: pod-reader
173-
rules:
174-
- apiGroups: [""] # "" 标明 core API 组
175-
resources: ["pods"]
176-
verbs: ["get", "watch", "list"]
177-
```
154+
{{% code_sample file="access/simple-role.yaml" %}}
178155

179156
<!--
180157
#### ClusterRole example
@@ -209,35 +186,6 @@ or across all namespaces (depending on how it is [bound](#rolebinding-and-cluste
209186
{{< glossary_tooltip text="Secret" term_id="secret" >}} 授予读访问权限,
210187
或者跨名字空间的访问权限(取决于该角色是如何[绑定](#rolebinding-and-clusterrolebinding)的):
211188

212-
<!--
213-
```yaml
214-
apiVersion: rbac.authorization.k8s.io/v1
215-
kind: ClusterRole
216-
metadata:
217-
# "namespace" omitted since ClusterRoles are not namespaced
218-
name: secret-reader
219-
rules:
220-
- apiGroups: [""]
221-
#
222-
# at the HTTP level, the name of the resource for accessing Secret
223-
# objects is "secrets"
224-
resources: ["secrets"]
225-
verbs: ["get", "watch", "list"]
226-
```
227-
-->
228-
```yaml
229-
apiVersion: rbac.authorization.k8s.io/v1
230-
kind: ClusterRole
231-
metadata:
232-
# "namespace" 被忽略,因为 ClusterRoles 不受名字空间限制
233-
name: secret-reader
234-
rules:
235-
- apiGroups: [""]
236-
# 在 HTTP 层面,用来访问 Secret 资源的名称为 "secrets"
237-
resources: ["secrets"]
238-
verbs: ["get", "watch", "list"]
239-
```
240-
241189
<!--
242190
The name of a Role or a ClusterRole object must be a valid
243191
[path segment name](/docs/concepts/overview/working-with-objects/names#path-segment-names).
@@ -270,7 +218,7 @@ RoleBinding 在指定的名字空间中执行授权,而 ClusterRoleBinding 在
270218
一个 RoleBinding 可以引用同一的名字空间中的任何 Role。
271219
或者,一个 RoleBinding 可以引用某 ClusterRole 并将该 ClusterRole 绑定到
272220
RoleBinding 所在的名字空间。
273-
如果你希望将某 ClusterRole 绑定到集群中所有名字空间,你要使用 ClusterRoleBinding。
221+
如果你希望将某 ClusterRole 绑定到集群中所有名字空间,你要使用 ClusterRoleBinding。
274222

275223
RoleBinding 或 ClusterRoleBinding 对象的名称必须是合法的
276224
[路径分段名称](/zh-cn/docs/concepts/overview/working-with-objects/names#path-segment-names)

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

+24-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ variables as well as some other useful variables:
496496
497497
`spec.validations[i].expression` 代表将使用 CEL 来计算表达式。
498498
要了解更多信息,请参阅 [CEL 语言规范](https://github.com/google/cel-spec)。
499-
CEL 表达式可以访问按 CEL 变量来组织的 Admission 请求/响应的内容,以及其他一些有用的变量 :
499+
CEL 表达式可以访问按 CEL 变量来组织的 Admission 请求/响应的内容,以及其他一些有用的变量
500500
501501
<!--
502502
- 'object' - The object from the incoming request. The value is null for DELETE requests.
@@ -922,3 +922,26 @@ The error message is similar to this.
922922
```console
923923
error: failed to create deployment: deployments.apps "invalid" is forbidden: ValidatingAdmissionPolicy 'image-matches-namespace-environment.policy.example.com' with binding 'demo-binding-test.example.com' denied request: only prod images are allowed in namespace default
924924
```
925+
926+
<!--
927+
## API kinds exempt from admission validation
928+
929+
There are certain API kinds that are exempt from admission-time validation checks. For example, you can't create a ValidatingAdmissionPolicy that prevents changes to ValidatingAdmissionPolicyBindings.
930+
931+
The list of exempt API kinds is:
932+
-->
933+
## 免于准入验证的 API 类别
934+
935+
某些 API 类别可以豁免准入时验证检查。例如,你无法创建阻止更改 ValidatingAdmissionPolicyBindings
936+
的 ValidatingAdmissionPolicy。
937+
938+
豁免准入验证的 API 类别列表如下:
939+
940+
* [ValidatingAdmissionPolicies]({{< relref "/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-v1/" >}})
941+
* [ValidatingAdmissionPolicyBindings]({{< relref "/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-binding-v1/" >}})
942+
* MutatingAdmissionPolicies
943+
* MutatingAdmissionPolicyBindings
944+
* [TokenReviews]({{< relref "/docs/reference/kubernetes-api/authentication-resources/token-review-v1/" >}})
945+
* [LocalSubjectAccessReviews]({{< relref "/docs/reference/kubernetes-api/authorization-resources/local-subject-access-review-v1/" >}})
946+
* [SelfSubjectAccessReviews]({{< relref "/docs/reference/kubernetes-api/authorization-resources/self-subject-access-review-v1/" >}})
947+
* [SelfSubjectReviews]({{< relref "/docs/reference/kubernetes-api/authentication-resources/self-subject-review-v1/" >}})
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
# "namespace" 被忽略,因为 ClusterRoles 不受名字空间限制
5+
name: secret-reader
6+
rules:
7+
- apiGroups: [""]
8+
# 在 HTTP 层面,用来访问 Secret 资源的名称为 "secrets"
9+
resources: ["secrets"]
10+
verbs: ["get", "watch", "list"]

Diff for: content/zh-cn/examples/access/simple-role.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
namespace: default
5+
name: pod-reader
6+
rules:
7+
- apiGroups: [""] # "" 标明 core API 组
8+
resources: ["pods"]
9+
verbs: ["get", "watch", "list"]

0 commit comments

Comments
 (0)