Skip to content

Commit 655b153

Browse files
committed
[zh] sync auth docs
1 parent 5cad983 commit 655b153

File tree

5 files changed

+188
-37
lines changed

5 files changed

+188
-37
lines changed

content/zh/docs/reference/access-authn-authz/abac.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Attribute-based access control (ABAC) defines an access control paradigm whereby
3838
To enable `ABAC` mode, specify `--authorization-policy-file=SOME_FILENAME` and `--authorization-mode=ABAC` on startup.
3939
4040
The file format is [one JSON object per line](http://jsonlines.org/). There
41-
should be no enclosing list or map, just one map per line.
41+
should be no enclosing list or map, only one map per line.
4242
4343
Each line is a "policy object", where each such object is a map with the following
4444
properties:
@@ -73,7 +73,7 @@ properties:
7373

7474
基于 `ABAC` 模式,可以这样指定策略文件 `--authorization-policy-file=SOME_FILENAME`
7575

76-
此文件格式是 [JSON Lines](https://jsonlines.org/)不应存在封闭的列表或映射,每行一个映射
76+
此文件格式是 [JSON Lines](https://jsonlines.org/)不应存在外层的列表或映射,每行应只有一个映射
7777

7878
每一行都是一个策略对象,策略对象是具有以下属性的映射:
7979

@@ -258,7 +258,7 @@ Kubectl 使用 api-server 的 `/api` 和 `/apis` 端点来发现服务资源类
258258
```
259259

260260
<!--
261-
[Complete file example](http://releases.k8s.io/{{< param "githubbranch" >}}/pkg/auth/authorizer/abac/example_policy_file.jsonl)
261+
[Complete file example](http://releases.k8s.io/{{< param "fullversion" >}}/pkg/auth/authorizer/abac/example_policy_file.jsonl)
262262

263263
## A quick note on service accounts
264264

@@ -270,7 +270,7 @@ system:serviceaccount:<namespace>:<serviceaccountname>
270270

271271
-->
272272

273-
[完整文件示例](https://releases.k8s.io/{{< param "githubbranch" >}}/pkg/auth/authorizer/abac/example_policy_file.jsonl)
273+
[完整文件示例](https://releases.k8s.io/{{< param "fullversion" >}}/pkg/auth/authorizer/abac/example_policy_file.jsonl)
274274

275275
## 服务帐户的快速说明
276276

content/zh/docs/reference/access-authn-authz/admission-controllers.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,30 @@ PodNodeSelector 允许 Pod 强制在特定标签的节点上运行。
11711171
另请参阅 PodTolerationRestriction 准入插件,该插件可防止 Pod 在特定污点的节点上运行。
11721172
{{< /note >}}
11731173

1174+
### PodSecurity {#podsecurity}
1175+
1176+
{{< feature-state for_k8s_version="v1.22" state="alpha" >}}
1177+
1178+
<!--
1179+
This is the replacement for the deprecated [PodSecurityPolicy](#podsecuritypolicy) admission controller
1180+
defined in the next section. This admission controller acts on creation and modification of the pod and
1181+
determines if it should be admitted based on the requested security context and the
1182+
[Pod Security Standards](/docs/concepts/security/pod-security-standards/).
1183+
1184+
See the [Pod Security Admission documentation](/docs/concepts/security/pod-security-admission/)
1185+
for more information.
1186+
-->
1187+
这是下节已被废弃的 [PodSecurityPolicy](#podsecuritypolicy) 准入控制器的替代品。
1188+
此准入控制器负责在创建和修改 Pod 时根据请求的安全上下文和
1189+
[Pod 安全标准](/zh/docs/concepts/security/pod-security-standards/)
1190+
来确定是否可以执行请求。
1191+
1192+
更多信息请参阅 [Pod 安全性准入控制器](/zh/docs/concepts/security/pod-security-admission/)。
1193+
11741194
### PodSecurityPolicy {#podsecuritypolicy}
11751195

1196+
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
1197+
11761198
<!--
11771199
This admission controller acts on creation and modification of the pod and determines if it should be admitted
11781200
based on the requested security context and the available Pod Security Policies.

content/zh/docs/reference/access-authn-authz/authorization.md

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,21 @@ a given action, and works regardless of the authorization mode used.
224224
```shell
225225
kubectl auth can-i create deployments --namespace dev
226226
```
227+
228+
<!-- The output is similar to this: -->
229+
输出类似于:
230+
227231
```
228232
yes
229233
```
230234

231235
```shell
232236
kubectl auth can-i create deployments --namespace prod
233237
```
238+
239+
<!-- The output is similar to this: -->
240+
输出类似于:
241+
234242
```
235243
no
236244
```
@@ -246,16 +254,39 @@ to determine what action other users can perform.
246254
```bash
247255
kubectl auth can-i list secrets --namespace dev --as dave
248256
```
257+
258+
<!-- The output is similar to this: -->
259+
输出类似于:
260+
249261
```
250262
no
251263
```
252264

265+
<!--
266+
Similarly, to check whether a Service Account named `dev-sa` in Namespace `dev`
267+
can list Pods in the Namespace `target`:
268+
-->
269+
类似地,检查名字空间 `dev` 里的 `dev-sa` 服务账号是否可以列举名字空间 `target` 里的 Pod:
270+
271+
```bash
272+
kubectl auth can-i list pods \
273+
--namespace target \
274+
--as system:serviceaccount:dev:dev-sa
275+
```
276+
277+
<!-- The output is similar to this: -->
278+
输出类似于:
279+
280+
```
281+
yes
282+
```
283+
253284
<!--
254285
`SelfSubjectAccessReview` is part of the `authorization.k8s.io` API group, which
255286
exposes the API server authorization to external services. Other resources in
256287
this group include:
257288
258-
* `SubjectAccessReview` - Access review for any user, not just the current one. Useful for delegating authorization decisions to the API server. For example, the kubelet and extension API servers use this to determine user access to their own APIs.
289+
* `SubjectAccessReview` - Access review for any user, not only the current one. Useful for delegating authorization decisions to the API server. For example, the kubelet and extension API servers use this to determine user access to their own APIs.
259290
* `LocalSubjectAccessReview` - Like `SubjectAccessReview` but restricted to a specific namespace.
260291
* `SelfSubjectRulesReview` - A review which returns the set of actions a user can perform within a namespace. Useful for users to quickly summarize their own access, or for UIs to hide/show actions.
261292
@@ -352,36 +383,64 @@ so an earlier module has higher priority to allow or deny a request.
352383
或拒绝请求。
353384

354385
<!--
355-
## Privilege escalation via pod creation
386+
## Privilege escalation via workload creation or edits {#privilege-escalation-via-pod-creation}
356387

357-
Users who have the ability to create pods in a namespace can potentially
358-
escalate their privileges within that namespace. They can create pods that
359-
access their privileges within that namespace. They can create pods that access
360-
secrets the user cannot themselves read, or that run under a service account
361-
with different/greater permissions.
388+
Users who can create/edit pods in a namespace, either directly or through a [controller](/docs/concepts/architecture/controller/)
389+
such as an operator, could escalate their privileges in that namespace.
362390
-->
363-
## 通过创建 Pod 提升权限
391+
## 通过创建或编辑工作负载提升权限 {#privilege-escalation-via-pod-creation}
364392

365-
能够在名字空间中创建 Pod 的用户可能会提升其在该名字空间内的权限。
366-
他们可以创建在该名字空间内访问其权限的 Pod。
367-
他们可以创建 Pod 访问用户自己无法读取的 Secret,或者在具有不同/更高权限的
368-
服务帐户下运行的 Pod 。
393+
能够在名字空间中创建或者编辑 Pod 的用户,
394+
无论是直接操作还是通过[控制器](/zh/docs/concepts/architecture/controller/)(例如,一个 Operator)来操作,
395+
都可以提升他们在该名字空间内的权限。
369396

370397
{{< caution >}}
371398
<!--
372-
System administrators, use care when granting access to pod creation. A user
373-
granted permission to create pods (or controllers that create pods) in the
374-
namespace can: read all secrets in the namespace; read all config maps in the
375-
namespace; and impersonate any service account in the namespace and take any
376-
action the account could take. This applies regardless of authorization mode.
399+
System administrators, use care when granting access to create or edit workloads.
400+
Details of how these can be misused are documented in [escalation paths](/docs/reference/access-authn-authz/authorization/#escalation-paths)
377401
-->
378-
系统管理员在授予对 Pod 创建的访问权限时要小心。
379-
被授予在名字空间中创建 Pod(或创建 Pod 的控制器)的权限的用户可以:
380-
读取名字空间中的所有 Secret;读取名字空间中的所有 ConfigMap;
381-
并模拟名字空间中的任意服务账号并执行账号可以执行的任何操作。
382-
无论采用何种鉴权方式,这都适用。
402+
系统管理员在授予对工作负载的创建或编辑的权限时要小心。
403+
关于这些权限如何被误用的详细信息请参阅
404+
[提升途径](#escalation-paths)
383405
{{< /caution >}}
384406

407+
<!--
408+
### Escalation paths {#escalation-paths}
409+
- Mounting arbitrary secrets in that namespace
410+
- Can be used to access secrets meant for other workloads
411+
- Can be used to obtain a more privileged service account's service account token
412+
- Using arbitrary Service Accounts in that namespace
413+
- Can perform Kubernetes API actions as another workload (impersonation)
414+
- Can perform any privileged actions that Service Account has
415+
- Mounting configmaps meant for other workloads in that namespace
416+
- Can be used to obtain information meant for other workloads, such as DB host names.
417+
- Mounting volumes meant for other workloads in that namespace
418+
- Can be used to obtain information meant for other workloads, and change it.
419+
-->
420+
### 提升途径 {#escalation-paths}
421+
- 挂载该名字空间内的任意 Secret
422+
- 可以用来访问其他工作负载专用的 Secret
423+
- 可以用来获取权限更高的服务账号的令牌
424+
- 使用该名字空间内的任意服务账号
425+
- 可以用另一个工作负载的身份来访问 Kubernetes API(伪装)
426+
- 可以执行该服务账号的任意特权操作
427+
- 挂载该名字空间里其他工作负载专用的 ConfigMap
428+
- 可以用来获取其他工作负载专用的信息,例如数据库主机名。
429+
- 挂载该名字空间里其他工作负载的卷
430+
- 可以用来获取其他工作负载专用的信息,并且更改它。
431+
432+
{{< caution >}}
433+
<!--
434+
System administrators should be cautious when deploying CRDs that
435+
change the above areas. These may open privilege escalations paths.
436+
This should be considered when deciding on your RBAC controls.
437+
-->
438+
系统管理员在部署改变以上部分的 CRD 的时候要小心。
439+
它们可能会打开权限提升的途径。
440+
在决定你的 RBAC 控制时应该考虑这方面的问题。
441+
{{< /caution >}}
442+
443+
385444
## {{% heading "whatsnext" %}}
386445

387446
<!--

content/zh/docs/reference/access-authn-authz/rbac.md

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ Because they are cluster-scoped, you can also use them to grant access to:
149149
* cluster-scoped resources (like {{< glossary_tooltip text="nodes" term_id="node" >}})
150150
* non-resource endpoints (like `/healthz`)
151151
* namespaced resources (like Pods), across all namespaces
152+
152153
For example: you can use a ClusterRole to allow a particular user to run
153154
`kubectl get pods -all-namespaces`
154155
-->
@@ -159,8 +160,9 @@ ClusterRole 可以和 Role 相同完成授权。
159160

160161
* 集群范围资源(比如 {{< glossary_tooltip text="节点(Node)" term_id="node" >}})
161162
* 非资源端点(比如 `/healthz`)
162-
* 跨名字空间访问的名字空间作用域的资源(如 Pods),比如,你可以使用
163-
ClusterRole 来允许某特定用户执行 `kubectl get pods --all-namespaces`
163+
* 跨名字空间访问的名字空间作用域的资源(如 Pods)
164+
165+
比如,你可以使用 ClusterRole 来允许某特定用户执行 `kubectl get pods --all-namespaces`
164166

165167
<!--
166168
Here is an example of a ClusterRole that can be used to grant read access to
@@ -429,11 +431,16 @@ rules:
429431

430432
{{< note >}}
431433
<!--
432-
You cannot restrict `create` or `deletecollection` requests by resourceName. For `create`, this
433-
limitation is because the object name is not known at authorization time.
434+
You cannot restrict `create` or `deletecollection` requests by their resource name.
435+
For `create`, this limitation is because the name of the new object may not be known at authorization time.
436+
If you restrict `list` or `watch` by resourceName, clients must include a `metadata.name` field selector in their `list` or `watch` request that matches the specified resourceName in order to be authorized.
437+
For example, `kubectl get configmaps --field-selector=metadata.name=my-configmap`
434438
-->
435-
你不能针对 `create` 或者 `deletecollection` 请求来实施 resourceName 限制。
436-
对于 `create` 操作而言,这是因为在鉴权时还不知道对象名称。
439+
你不能使用资源名字来限制 `create` 或者 `deletecollection` 请求。
440+
对于 `create` 请求而言,这是因为在鉴权时可能还不知道新对象的名字。
441+
如果你使用 resourceName 来限制 `list` 或者 `watch` 请求,
442+
客户端必须在它们的 `list` 或者 `watch` 请求里包含一个与指定的 resourceName 匹配的 `metadata.name` 字段选择器。
443+
例如,`kubectl get configmaps --field-selector=metadata.name=my-configmap`
437444
{{< /note >}}
438445

439446
<!--
@@ -1051,12 +1058,18 @@ When used in a <b>RoleBinding</b>, it gives full control over every resource in
10511058
Allows admin access, intended to be granted within a namespace using a <b>RoleBinding</b>.
10521059
If used in a <b>RoleBinding</b>, allows read/write access to most resources in a namespace,
10531060
including the ability to create roles and rolebindings within the namespace.
1054-
It does not allow write access to resource quota or to the namespace itself.
1061+
This role does not allow write access to resource quota or to the namespace itself.
1062+
This role also does not allow write access to Endpoints in clusters created
1063+
using Kubernetes v1.22+. More information is available in the
1064+
["Write Access for Endpoints" section](#write-access-for-endpoints).
10551065
-->
10561066
允许管理员访问权限,旨在使用 <b>RoleBinding</b> 在名字空间内执行授权。
1067+
10571068
如果在 <b>RoleBinding</b> 中使用,则可授予对名字空间中的大多数资源的读/写权限,
10581069
包括创建角色和角色绑定的能力。
1059-
但是它不允许对资源配额或者名字空间本身进行写操作。
1070+
此角色不允许对资源配额或者名字空间本身进行写操作。
1071+
此角色也不允许对 Kubernetes v1.22+ 创建的 Endpoints 进行写操作。
1072+
更多信息参阅[“Endpoints 写权限”小节](#write-access-for-endpoints)。
10601073
</td>
10611074
</tr>
10621075
<tr>
@@ -1071,12 +1084,17 @@ Allows read/write access to most objects in a namespace.
10711084
This role does not allow viewing or modifying roles or role bindings.
10721085
However, this role allows accessing Secrets and running Pods as any ServiceAccount in
10731086
the namespace, so it can be used to gain the API access levels of any ServiceAccount in
1074-
the namespace.
1087+
the namespace. This role also does not allow write access to Endpoints in
1088+
clusters created using Kubernetes v1.22+. More information is available in the
1089+
["Write Access for Endpoints" section](#write-access-for-endpoints).
10751090
-->
10761091
允许对名字空间的大多数对象进行读/写操作。
1092+
10771093
它不允许查看或者修改角色或者角色绑定。
10781094
不过,此角色可以访问 Secret,以名字空间中任何 ServiceAccount 的身份运行 Pods,
10791095
所以可以用来了解名字空间内所有服务账户的 API 访问级别。
1096+
此角色也不允许对 Kubernetes v1.22+ 创建的 Endpoints 进行写操作。
1097+
更多信息参阅[“Endpoints 写操作”小节](#write-access-for-endpoints)。
10801098
</td>
10811099
</tr>
10821100
<tr>
@@ -1327,10 +1345,10 @@ Role for the <a href="https://github.com/kubernetes/node-problem-detector">node-
13271345
<td>无</td>
13281346
<td>
13291347
<!--
1330-
Allows access to the resources required by most <a href="/docs/concepts/storage/persistent-volumes/#provisioner">dynamic volume provisioners</a>.
1348+
Allows access to the resources required by most <a href="/docs/concepts/storage/persistent-volumes/#dynamic">dynamic volume provisioners</a>.
13311349
-->
13321350
允许访问大部分
1333-
<a href="/docs/concepts/storage/persistent-volumes/#provisioner">动态卷驱动
1351+
<a href="/zh/docs/concepts/storage/persistent-volumes/#dynamic">动态卷驱动
13341352
</a>
13351353
所需要的资源。</td>
13361354
</tr>
@@ -1957,6 +1975,40 @@ In order from most secure to least secure, the approaches are:
19571975
--group=system:serviceaccounts
19581976
```
19591977

1978+
<!--
1979+
## Write access for Endpoints
1980+
1981+
Kubernetes clusters created before Kubernetes v1.22 include write access to
1982+
Endpoints in the aggregated "edit" and "admin" roles. As a mitigation for
1983+
[CVE-2021-25740](https://github.com/kubernetes/kubernetes/issues/103675), this
1984+
access is not part of the aggregated roles in clusters that you create using
1985+
Kubernetes v1.22 or later.
1986+
1987+
Existing clusters that have been upgraded to Kubernetes v1.22 will not be
1988+
subject to this change. The [CVE
1989+
announcement](https://github.com/kubernetes/kubernetes/issues/103675) includes
1990+
guidance for restricting this access in existing clusters.
1991+
1992+
If you want new clusters to retain this level of access in the aggregated roles,
1993+
you can create the following ClusterRole:
1994+
1995+
{{< codenew file="access/endpoints-aggregated.yaml" >}}
1996+
-->
1997+
## Endpoints 写权限 {#write-access-for-endpoints}
1998+
1999+
在 Kubernetes v1.22 之前版本创建的集群里,
2000+
"edit" 和 "admin" 聚合角色包含对 Endpoints 的写权限。
2001+
作为 [CVE-2021-25740](https://github.com/kubernetes/kubernetes/issues/103675) 的缓解措施,
2002+
此访问权限不包含在 Kubernetes 1.22 以及更高版本集群的聚合角色里。
2003+
2004+
升级到 Kubernetes v1.22 版本的现有集群不会包括此变化。
2005+
[CVE 公告](https://github.com/kubernetes/kubernetes/issues/103675)
2006+
包含了在现有集群里限制此访问权限的指引。
2007+
2008+
如果你希望在新集群的聚合角色里保留此访问权限,你可以创建下面的 ClusterRole:
2009+
2010+
{{< codenew file="access/endpoints-aggregated.yaml" >}}
2011+
19602012
<!--
19612013
## Upgrading from ABAC
19622014

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
annotations:
5+
kubernetes.io/description: |-
6+
Add endpoints write permissions to the edit and admin roles. This was
7+
removed by default in 1.22 because of CVE-2021-25740. See
8+
https://issue.k8s.io/103675. This can allow writers to direct LoadBalancer
9+
or Ingress implementations to expose backend IPs that would not otherwise
10+
be accessible, and can circumvent network policies or security controls
11+
intended to prevent/isolate access to those backends.
12+
labels:
13+
rbac.authorization.k8s.io/aggregate-to-edit: "true"
14+
name: custom:aggregate-to-edit:endpoints # you can change this if you wish
15+
rules:
16+
- apiGroups: [""]
17+
resources: ["endpoints"]
18+
verbs: ["create", "delete", "deletecollection", "patch", "update"]

0 commit comments

Comments
 (0)