kubernetes - Kubernetes 角色应该授予对所有资源的访问权限,但它会忽略某些资源
问题描述
该角色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 将 Role 与 ServiceAccount 相关联,但不幸的是,此 ServiceAccount 无权访问Pod
、Service
、和Resources。这些资源都是API 组的一部分。但是,所有其他常见的工作负载都可以工作。这是为什么?Secret
ConfigMap
Endpoint
core
解决方案
核心组,也称为遗留组,位于 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
推荐阅读
- c# - 我们如何在 Windows 商店 + C# 中存储和检索包含私钥的证书
- python - 使用python从日志文件计算增量时间
- hashcat - hashcat [命令行错误:选项 'polly' 注册了多次!& LLVM 错误:注册的命令行选项不一致]
- c++ - 如何处理 cgo 中打包结构中的 char *?
- javascript - 使用 javascript 创建 `select` 元素
- angular - 角度 2+,垫表 - 过滤不适用于模型中的模型
- reactjs - 开玩笑 toMatchInlineSnapshot 一直显示“不允许操作,scandir 消息”
- javascript - AgGrid 自定义标题过滤器未显示
- c++ - 为什么我的 elseif 语句永远不会执行
- java - 为什么读取文件名中带有“:”的测试资源会导致 NPE?