| admin |
-
无 |
-
| 无 |
-
| 无 |
-
@@ -1102,7 +1350,7 @@ It does not allow viewing roles or rolebindings.
This role does not allow viewing Secrets, since reading
the contents of Secrets enables access to ServiceAccount credentials
in the namespace, which would allow API access as any ServiceAccount
-in the namespace (a form of privilege escalation).
+in the namespace (a form of privilege escalation).
-->
此角色不允许查看 Secrets,因为读取 Secret 的内容意味着可以访问名字空间中
ServiceAccount 的凭据信息,进而允许利用名字空间中任何 ServiceAccount 的
@@ -1118,7 +1366,7 @@ ServiceAccount 的凭据信息,进而允许利用名字空间中任何 Service
### 核心组件角色 {#core-component-roles}
-
+
| system:kube-scheduler 用户 |
-
允许访问 {{< glossary_tooltip term_id="kube-scheduler" text="scheduler" >}}
@@ -1148,8 +1396,8 @@ Allows access to the resources required by the {{< glossary_tooltip term_id="kub
|
| system:volume-scheduler |
-
system:kube-scheduler 用户 |
@@ -1161,23 +1409,23 @@ Allows access to the volume resources required by the kube-scheduler component.
|
| system:kube-controller-manager |
-
system:kube-controller-manager 用户 |
-
允许访问{{< glossary_tooltip term_id="kube-controller-manager" text="控制器管理器" >}}
组件所需要的资源。
-各个控制回路所需要的权限在控制器角色 详述。
+各个控制回路所需要的权限在控制器角色详述。
|
| system:node |
-
无 |
@@ -1187,17 +1435,17 @@ Allows access to resources required by the kubelet, including read access to
-->
允许访问 kubelet 所需要的资源,包括对所有 Secret 的读操作和对所有 Pod 状态对象的写操作。
-
-你应该使用 Node 鉴权组件 和
-NodeRestriction 准入插件
-而不是 system:node 角色。同时基于 kubelet 上调度执行的 Pod 来授权
+你应该使用 Node 鉴权组件和
+NodeRestriction 准入插件而不是
+system:node 角色。同时基于 kubelet 上调度执行的 Pod 来授权
kubelet 对 API 的访问。
-
system:node 角色的意义仅是为了与从 v1.8 之前版本升级而来的集群兼容。
@@ -1220,13 +1468,13 @@ The system:node role only exists for compatibility with Kubernetes clus
### 其他组件角色 {#other-component-roles}
-
+
-
| 默认 ClusterRole |
默认 ClusterRoleBinding |
@@ -1236,12 +1484,12 @@ The system:node role only exists for compatibility with Kubernetes clus
| system:auth-delegator |
-
无 |
-
@@ -1251,8 +1499,8 @@ This is commonly used by add-on API servers for unified authentication and autho
|
| system:heapster |
-
无 |
@@ -1264,8 +1512,8 @@ Role for the Heapster compo
|
| system:kube-aggregator |
-
无 |
@@ -1273,36 +1521,34 @@ Role for the Heapster compo
| system:kube-dns |
-
-在 kube-system 名字空间中的 kube-dns 服务账户 |
+在 kube-system 名字空间中的 kube-dns 服务账户 |
-为 kube-dns 组件定义的角色。
- |
+为 kube-dns 组件定义的角色。 |
| system:kubelet-api-admin |
-
无 |
-
允许 kubelet API 的完全访问权限。
|
-
+
| system:node-bootstrapper |
-
无 |
-
@@ -1313,12 +1559,12 @@ Allows access to the resources required to perform
|
| system:node-problem-detector |
-
无 |
-
为 node-problem-detector 组件定义的角色。
@@ -1326,30 +1572,30 @@ Role for the node-
|
| system:persistent-volume-provisioner |
-
无 |
-
允许访问大部分
-动态卷驱动
-
-所需要的资源。 |
+动态卷驱动
+所需要的资源。
+
| system:monitoring |
-
system:monitoring 组 |
@@ -1368,10 +1614,10 @@ Allows read access to control-plane monitoring endpoints
The Kubernetes {{< glossary_tooltip term_id="kube-controller-manager" text="controller manager" >}} runs
{{< glossary_tooltip term_id="controller" text="controllers" >}} that are built in to the Kubernetes
control plane.
-When invoked with `-use-service-account-credentials`, kube-controller-manager starts each controller
+When invoked with `--use-service-account-credentials`, kube-controller-manager starts each controller
using a separate service account.
Corresponding roles exist for each built-in controller, prefixed with `system:controller:`.
-If the controller manager is not started with `-use-service-account-credentials`, it runs all control loops
+If the controller manager is not started with `--use-service-account-credentials`, it runs all control loops
using its own credential, which must be granted all the relevant roles.
These roles include:
-->
@@ -1379,12 +1625,12 @@ These roles include:
Kubernetes {{< glossary_tooltip term_id="kube-controller-manager" text="控制器管理器" >}}
运行内建于 Kubernetes 控制面的{{< glossary_tooltip term_id="controller" text="控制器" >}}。
-当使用 `--use-service-account-credentials` 参数启动时, kube-controller-manager
+当使用 `--use-service-account-credentials` 参数启动时,kube-controller-manager
使用单独的服务账户来启动每个控制器。
每个内置控制器都有相应的、前缀为 `system:controller:` 的角色。
如果控制管理器启动时未设置 `--use-service-account-credentials`,
它使用自己的身份凭据来运行所有的控制器,该身份必须被授予所有相关的角色。
-这些角色包括:
+这些角色包括:
* `system:controller:attachdetach-controller`
* `system:controller:certificate-controller`
@@ -1415,12 +1661,12 @@ Kubernetes {{< glossary_tooltip term_id="kube-controller-manager" text="控制
* `system:controller:ttl-controller`
-## 初始化与预防权限提升
+## 初始化与预防权限提升 {#privilege-escalation-prevention-and-bootstrapping}
RBAC API 会阻止用户通过编辑角色或者角色绑定来提升权限。
由于这一点是在 API 级别实现的,所以在 RBAC 鉴权组件未启用的状态下依然可以正常工作。
@@ -1434,7 +1680,7 @@ You can only create/update a role if at least one of the following things is tru
(cluster-wide for a ClusterRole, within the same namespace or cluster-wide for a Role).
2. You are granted explicit permission to perform the `escalate` verb on the `roles` or `clusterroles` resource in the `rbac.authorization.k8s.io` API group.
-->
-### 对角色创建或更新的限制
+### 对角色创建或更新的限制 {#restrictions-on-role-creation-or-update}
只有在符合下列条件之一的情况下,你才能创建/更新角色:
@@ -1470,7 +1716,7 @@ You can only create/update a role binding if you already have all the permission
For example, if `user-1` does not have the ability to list Secrets cluster-wide, they cannot create a ClusterRoleBinding
to a role that grants that permission. To allow a user to create/update role bindings:
-->
-### 对角色绑定创建或更新的限制
+### 对角色绑定创建或更新的限制 {#restrictions-on-role-binding-creation-or-update}
只有你已经具有了所引用的角色中包含的全部权限时,或者你被授权在所引用的角色上执行 `bind`
动词时,你才可以创建或更新角色绑定。这里的权限与角色绑定的作用域相同。
@@ -1495,6 +1741,37 @@ For example, this ClusterRole and RoleBinding would allow `user-1` to grant othe
例如,下面的 ClusterRole 和 RoleBinding 将允许用户 `user-1` 把名字空间 `user-1-namespace`
中的 `admin`、`edit` 和 `view` 角色赋予其他用户:
+
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
@@ -1529,33 +1806,32 @@ subjects:
When bootstrapping the first roles and role bindings, it is necessary for the initial user to grant permissions they do not yet have.
To bootstrap initial roles and role bindings:
-* Use a credential with the `system:masters` group, which is bound to the `cluster-admin` super-user role by the default bindings.
-* If your API server runs with the insecure port enabled (`-insecure-port`), you can also make API calls via that port, which does not enforce authentication or authorization.
+* Use a credential with the "system:masters" group, which is bound to the "cluster-admin" super-user role by the default bindings.
+* If your API server runs with the insecure port enabled (`--insecure-port`), you can also make API calls via that port, which does not enforce authentication or authorization.
-->
当启动引导第一个角色和角色绑定时,需要为初始用户授予他们尚未拥有的权限。
对初始角色和角色绑定进行初始化时需要:
* 使用用户组为 `system:masters` 的凭据,该用户组由默认绑定关联到 `cluster-admin`
这个超级用户角色。
-* 如果你的 API 服务器启动时启用了不安全端口(使用 `--insecure-port`), 你也可以通过
- 该端口调用 API ,这样的操作会绕过身份验证或鉴权。
+* 如果你的 API 服务器启动时启用了不安全端口(使用 `--insecure-port`),你也可以通过
+ 该端口调用 API,这样的操作会绕过身份验证或鉴权。
+## 一些命令行工具 {#command-line-utilities}
### `kubectl create role`
-Creates a `Role` object defining permissions within a single namespace. Examples:
+
-## 一些命令行工具
-
-### `kubectl create role`
-
创建 Role 对象,定义在某一名字空间中的权限。例如:
-* 创建名称为 "pod-reader" 的 Role 对象,允许用户对 Pods 执行 `get`、`watch` 和 `list` 操作:
+* 创建名称为 “pod-reader” 的 Role 对象,允许用户对 Pods 执行 `get`、`watch` 和 `list` 操作:
```shell
kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods
@@ -1564,16 +1840,16 @@ Creates a `Role` object defining permissions within a single namespace. Examples
-* 创建名称为 "pod-reader" 的 Role 对象并指定 `resourceNames`:
+* 创建名称为 “pod-reader” 的 Role 对象并指定 `resourceNames`:
```shell
kubectl create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod
```
-* 创建名为 "foo" 的 Role 对象并指定 `apiGroups`:
+* 创建名为 “foo” 的 Role 对象并指定 `apiGroups`:
```shell
kubectl create role foo --verb=get,list,watch --resource=replicasets.apps
@@ -1582,7 +1858,7 @@ Creates a `Role` object defining permissions within a single namespace. Examples
-* 创建名为 "foo" 的 Role 对象并指定子资源权限:
+* 创建名为 “foo” 的 Role 对象并指定子资源权限:
```shell
kubectl create role foo --verb=get,list,watch --resource=pods,pods/status
@@ -1591,7 +1867,7 @@ Creates a `Role` object defining permissions within a single namespace. Examples
-* 创建名为 "my-component-lease-holder" 的 Role 对象,使其具有对特定名称的
+* 创建名为 “my-component-lease-holder” 的 Role 对象,使其具有对特定名称的
资源执行 get/update 的权限:
```shell
@@ -1607,7 +1883,7 @@ Creates a ClusterRole. Examples:
-->
创建 ClusterRole 对象。例如:
-* 创建名称为 "pod-reader" 的 ClusterRole`对象,允许用户对 Pods 对象执行 `get`、
+* 创建名称为 “pod-reader” 的 ClusterRole 对象,允许用户对 Pods 对象执行 `get`、
`watch` 和 `list` 操作:
```shell
@@ -1617,7 +1893,7 @@ Creates a ClusterRole. Examples:
-* 创建名为 "pod-reader" 的 ClusterRole 对象并指定 `resourceNames`:
+* 创建名为 “pod-reader” 的 ClusterRole 对象并指定 `resourceNames`:
```shell
kubectl create clusterrole pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod
@@ -1626,7 +1902,7 @@ Creates a ClusterRole. Examples:
-* 创建名为 "foo" 的 ClusterRole 对象并指定 `apiGroups`:
+* 创建名为 “foo” 的 ClusterRole 对象并指定 `apiGroups`:
```shell
kubectl create clusterrole foo --verb=get,list,watch --resource=replicasets.apps
@@ -1635,7 +1911,7 @@ Creates a ClusterRole. Examples:
-* 创建名为 "foo" 的 ClusterRole 对象并指定子资源:
+* 创建名为 “foo” 的 ClusterRole 对象并指定子资源:
```shell
kubectl create clusterrole foo --verb=get,list,watch --resource=pods,pods/status
@@ -1644,7 +1920,7 @@ Creates a ClusterRole. Examples:
-* 创建名为 "foo" 的 ClusterRole 对象并指定 `nonResourceURL`:
+* 创建名为 “foo” 的 ClusterRole 对象并指定 `nonResourceURL`:
```shell
kubectl create clusterrole "foo" --verb=get --non-resource-url=/logs/*
@@ -1653,7 +1929,7 @@ Creates a ClusterRole. Examples:
-* 创建名为 "monitoring" 的 ClusterRole 对象并指定 `aggregationRule`:
+* 创建名为 “monitoring” 的 ClusterRole 对象并指定 `aggregationRule`:
```shell
kubectl create clusterrole monitoring --aggregation-rule="rbac.example.com/aggregate-to-monitoring=true"
@@ -1668,7 +1944,7 @@ Grants a Role or ClusterRole within a specific namespace. Examples:
-->
在特定的名字空间中对 `Role` 或 `ClusterRole` 授权。例如:
-* 在名字空间 "acme" 中,将名为 `admin` 的 ClusterRole 中的权限授予名称 "bob" 的用户:
+* 在名字空间 “acme” 中,将名为 `admin` 的 ClusterRole 中的权限授予名称 “bob” 的用户:
```shell
kubectl create rolebinding bob-admin-binding --clusterrole=admin --user=bob --namespace=acme
@@ -1677,7 +1953,7 @@ Grants a Role or ClusterRole within a specific namespace. Examples:
-* 在名字空间 "acme" 中,将名为 `view` 的 ClusterRole 中的权限授予名字空间 "acme"
+* 在名字空间 “acme” 中,将名为 `view` 的 ClusterRole 中的权限授予名字空间 “acme”
中名为 `myapp` 的服务账户:
```shell
@@ -1687,8 +1963,8 @@ Grants a Role or ClusterRole within a specific namespace. Examples:
-* 在名字空间 "acme" 中,将名为 `view` 的 ClusterRole 对象中的权限授予名字空间
- "myappnamespace" 中名称为 `myapp` 的服务账户:
+* 在名字空间 “acme” 中,将名为 `view` 的 ClusterRole 对象中的权限授予名字空间
+ “myappnamespace” 中名称为 `myapp` 的服务账户:
```shell
kubectl create rolebinding myappnamespace-myapp-view-binding --clusterrole=view --serviceaccount=myappnamespace:myapp --namespace=acme
@@ -1704,7 +1980,7 @@ Grants a ClusterRole across the entire cluster (all namespaces). Examples:
在整个集群(所有名字空间)中用 ClusterRole 授权。例如:
* 在整个集群范围,将名为 `cluster-admin` 的 ClusterRole 中定义的权限授予名为
- "root" 用户:
+ “root” 用户:
```shell
kubectl create clusterrolebinding root-cluster-admin-binding --clusterrole=cluster-admin --user=root
@@ -1714,7 +1990,7 @@ Grants a ClusterRole across the entire cluster (all namespaces). Examples:
* Across the entire cluster, grant the permissions in the "system:node-proxier" ClusterRole to a user named "system:kube-proxy":
-->
* 在整个集群范围内,将名为 `system:node-proxier` 的 ClusterRole 的权限授予名为
- "system:kube-proxy" 的用户:
+ “system:kube-proxy” 的用户:
```shell
kubectl create clusterrolebinding kube-proxy-binding --clusterrole=system:node-proxier --user=system:kube-proxy
@@ -1723,8 +1999,8 @@ Grants a ClusterRole across the entire cluster (all namespaces). Examples:
-* 在整个集群范围内,将名为 `view` 的 ClusterRole 中定义的权限授予 "acme" 名字空间中
- 名为 "myapp" 的服务账户:
+* 在整个集群范围内,将名为 `view` 的 ClusterRole 中定义的权限授予 “acme” 名字空间中
+ 名为 “myapp” 的服务账户:
```shell
kubectl create clusterrolebinding myapp-view-binding --clusterrole=view --serviceaccount=acme:myapp
@@ -1762,7 +2038,7 @@ Examples:
* 测试应用 RBAC 对象的清单文件,显示将要进行的更改:
```shell
- kubectl auth reconcile -f my-rbac-rules.yaml --dry-run
+ kubectl auth reconcile -f my-rbac-rules.yaml --dry-run=client
```
-* 应用 RBAC 对象的清单文件, 删除角色中的额外权限和绑定中的其他主体:
+* 应用 RBAC 对象的清单文件,删除角色中的额外权限和绑定中的其他主体:
```shell
kubectl auth reconcile -f my-rbac-rules.yaml --remove-extra-subjects --remove-extra-permissions
```
-查看 CLI 帮助获取详细的用法。
-
-
## 服务账户权限 {#service-account-permissions}
@@ -1805,9 +2077,9 @@ Broader grants can give unnecessary (and potentially escalating) API access to s
但是不会对 `kube-system` 名字空间之外的服务账户授予权限。
(除了授予所有已认证用户的发现权限)
-这使得你可以根据需要向特定服务账户授予特定权限。
+这使得你可以根据需要向特定 ServiceAccount 授予特定权限。
细粒度的角色绑定可带来更好的安全性,但需要更多精力管理。
-粗粒度的授权可能导致服务账户被授予不必要的 API 访问权限(甚至导致潜在的权限提升),
+粗粒度的授权可能导致 ServiceAccount 被授予不必要的 API 访问权限(甚至导致潜在的权限提升),
但更易于管理。
这要求应用在其 Pod 规约中指定 `serviceAccountName`,
- 并额外创建服务账户(包括通过 API、应用程序清单、`kubectl create serviceaccount` 等)。
+ 并额外创建服务账户(包括通过 API、应用程序清单、`kubectl create serviceaccount` 等)。
- 例如,在名字空间 "my-namespace" 中授予服务账户 "my-sa" 只读权限:
+ 例如,在名字空间 “my-namespace” 中授予服务账户 “my-sa” 只读权限:
```shell
kubectl create rolebinding my-sa-view \
@@ -1840,7 +2112,7 @@ In order from most secure to least secure, the approaches are:
-2. 将角色授予某名字空间中的 "default" 服务账户
+2. 将角色授予某名字空间中的 “default” 服务账户
- 如果某应用没有指定 `serviceAccountName`,那么它将使用 "default" 服务账户。
+ 如果某应用没有指定 `serviceAccountName`,那么它将使用 “default” 服务账户。
{{< note >}}
"default" 服务账户所具有的权限会被授予给名字空间中所有未指定
@@ -1874,20 +2146,20 @@ In order from most secure to least secure, the approaches are:
To allow those add-ons to run with super-user access, grant cluster-admin
permissions to the "default" service account in the `kube-system` namespace.
- {{< note >}}
+ {{< caution >}}
Enabling this means the `kube-system` namespace contains Secrets
- that grant super-user access to the API.
- {{< /note >}}
+ that grant super-user access to your cluster's API.
+ {{< /caution >}}
-->
- 许多[插件组件](/zh/docs/concepts/cluster-administration/addons/) 在 `kube-system`
- 名字空间以 "default" 服务账户运行。
+ 许多[插件组件](/zh/docs/concepts/cluster-administration/addons/)在 `kube-system`
+ 名字空间以 “default” 服务账户运行。
要允许这些插件组件以超级用户权限运行,需要将集群的 `cluster-admin` 权限授予
- `kube-system` 名字空间中的 "default" 服务账户。
+ `kube-system` 名字空间中的 “default” 服务账户。
- {{< note >}}
- 启用这一配置意味着在 `kube-system` 名字空间中包含以超级用户账号来访问 API
+ {{< caution >}}
+ 启用这一配置意味着在 `kube-system` 名字空间中包含以超级用户账号来访问集群 API
的 Secrets。
- {{< /note >}}
+ {{< /caution >}}
```shell
kubectl create clusterrolebinding add-on-cluster-admin \
@@ -1907,7 +2179,7 @@ In order from most secure to least secure, the approaches are:
如果你想要名字空间中所有应用都具有某角色,无论它们使用的什么服务账户,
可以将角色授予该名字空间的服务账户组。
- 例如,在名字空间 "my-namespace" 中的只读权限授予该名字空间中的所有服务账户:
+ 例如,在名字空间 “my-namespace” 中的只读权限授予该名字空间中的所有服务账户:
```shell
kubectl create rolebinding serviceaccounts-view \
@@ -1949,7 +2221,7 @@ In order from most secure to least secure, the approaches are:
-->
5. 授予超级用户访问权限给集群范围内的所有服务帐户(强烈不鼓励)
- 如果你不关心如何区分权限,你可以将超级用户访问权限授予所有服务账户。
+ 如果你不在乎如何区分权限,你可以将超级用户访问权限授予所有服务账户。
{{< warning >}}
这样做会允许所有应用都对你的集群拥有完全的访问权限,并将允许所有能够读取
@@ -1978,19 +2250,16 @@ guidance for restricting this access in existing clusters.
If you want new clusters to retain this level of access in the aggregated roles,
you can create the following ClusterRole:
-
-{{< codenew file="access/endpoints-aggregated.yaml" >}}
-->
## Endpoints 写权限 {#write-access-for-endpoints}
在 Kubernetes v1.22 之前版本创建的集群里,
-"edit" 和 "admin" 聚合角色包含对 Endpoints 的写权限。
+“edit” 和 “admin” 聚合角色包含对 Endpoints 的写权限。
作为 [CVE-2021-25740](https://github.com/kubernetes/kubernetes/issues/103675) 的缓解措施,
此访问权限不包含在 Kubernetes 1.22 以及更高版本集群的聚合角色里。
升级到 Kubernetes v1.22 版本的现有集群不会包括此变化。
-[CVE 公告](https://github.com/kubernetes/kubernetes/issues/103675)
-包含了在现有集群里限制此访问权限的指引。
+[CVE 公告](https://github.com/kubernetes/kubernetes/issues/103675)包含了在现有集群里限制此访问权限的指引。
如果你希望在新集群的聚合角色里保留此访问权限,你可以创建下面的 ClusterRole:
@@ -2010,7 +2279,7 @@ and controllers, but grant *no permissions* to service accounts outside the `kub
While far more secure, this can be disruptive to existing workloads expecting to automatically receive API permissions.
Here are two approaches for managing this transition:
-->
-## 从 ABAC 升级
+## 从 ABAC 升级 {#upgrading-from-abac}
原来运行较老版本 Kubernetes 的集群通常会使用限制宽松的 ABAC 策略,
包括授予所有服务帐户全权访问 API 的能力。
@@ -2023,19 +2292,19 @@ Here are two approaches for managing this transition:
这里有两种方法来完成这种转换:
### 并行鉴权 {#parallel-authorizers}
-同时运行 RBAC 和 ABAC 鉴权模式, 并指定包含
+同时运行 RBAC 和 ABAC 鉴权模式,并指定包含
[现有的 ABAC 策略](/zh/docs/reference/access-authn-authz/abac/#policy-file-format)
的策略文件:
```shell
---authorization-mode=RBAC,ABAC --authorization-policy-file=mypolicy.json
+--authorization-mode=...,RBAC,ABAC --authorization-policy-file=mypolicy.json
```
-如果 API 服务器启动时,RBAC 组件的日志级别为 5 或更高(`--vmodule=rbac*=5` 或 `--v=5`),
-你可以在 API 服务器的日志中看到 RBAC 的细节 (前缀 `RBAC:`)
+如果 kube-apiserver 启动时,RBAC 组件的日志级别为 5 或更高(`--vmodule=rbac*=5` 或 `--v=5`),
+你可以在 API 服务器的日志中看到 RBAC 拒绝的细节(前缀 `RBAC`)
你可以使用这些信息来确定需要将哪些角色授予哪些用户、组或服务帐户。
-一旦你[将角色授予服务账户](#service-account-permissions) ,工作负载运行时
-在服务器日志中没有出现 RBAC 拒绝消息,就可以删除 ABAC 鉴权器。
+一旦你[将角色授予服务账户](#service-account-permissions)且工作负载运行时,
+服务器日志中没有出现 RBAC 拒绝消息,就可以删除 ABAC 鉴权器。
### 宽松的 RBAC 权限 {#permissive-rbac-permissions}
-你可以使用 RBAC 角色绑定在多个场合使用宽松的策略。
+你可以使用 RBAC 角色绑定复制宽松的 ABAC 策略。
{{< warning >}}
在你完成到 RBAC 的迁移后,应该调整集群的访问控制,确保相关的策略满足你的信息安全需求。
-
| |