该角色namespace-limited
应具有对名称空间内(指定API组的)所有资源的完全访问权限。我的角色清单如下所示:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: namespace-limited
namespace: restricted-xample
rules:
- apiGroups:
- core
- apps
- batch
- networking.k8s.io
resources: ["*"] # asterisk to grant access to all resources of the specified api groups
verbs: ["*"]
我相关的使用RoleBinding角色的ServiceAccount可惜这ServiceAccount已经用不上Pod
,Service
,Secret
,ConfigMap
和Endpoint
资源。这些资源都是core
API组的一部分。所有其他常见工作负载都可以工作。这是为什么?
核心组(也称为旧组)位于REST路径上/api/v1
并使用apiVersion: v1
您需要""
用于核心API组。
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: restricted-xample
name: namespace-limited
rules:
- apiGroups: ["", "apps", "batch", "networking.k8s.io"] # "" indicates the core API group
resources: ["*"]
verbs: ["*"]
要测试服务帐户的权限,请使用以下命令
kubectl auth can-i get pods --as=system:serviceaccount:restricted-xample:default -n restricted-xample
kubectl auth can-i get secrets --as=system:serviceaccount:restricted-xample:default -n restricted-xample
kubectl auth can-i get configmaps --as=system:serviceaccount:restricted-xample:default -n restricted-xample
kubectl auth can-i get endpoints --as=system:serviceaccount:restricted-xample:default -n restricted-xample
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句