VBo*_*Boi 4 rbac user-roles kubernetes
我试图允许我的组织中的一些用户将端口转发到 Kubernetes 中的生产命名空间。但是,我不希望他们能够将端口转发到所有服务。我想限制仅访问某些服务。这可能吗?
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: allow-port-forward-for-deployment-a
rules:
- apiGroups: [""]
resources: ["pods/portforward"]
verbs: ["get", "list", "create"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: allow-port-forward-for-deployment-a
namespace: production
subjects:
- kind: User
name: "xyz@org.com"
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: allow-port-forward-for-deployment-a
apiGroup: rbac.authorization.k8s.io
Run Code Online (Sandbox Code Playgroud)
上面的设置允许所有服务,但我不想要这样。
我相信你不能。根据文档
\n\n\n\n\n还可以通过列表按名称引用某些请求的资源
\n\nresourceNames。指定后,可以将请求限制为资源的各个实例。要将主题限制为仅 \n \xe2\x80\x9cget\xe2\x80\x9d 和 \xe2\x80\x9cupdate\xe2\x80\x9d 单个配置映射,您可以编写:Run Code Online (Sandbox Code Playgroud)\n\napiVersion: rbac.authorization.k8s.io/v1\nkind: Role\nmetadata:\n namespace: default\n name: configmap-updater\nrules:\n- apiGroups: [""]\n resources: ["configmaps"]\n resourceNames: ["my-configmap"]\n verbs: ["update", "get"]\n请注意,创建请求不能受资源名称限制,因为在授权时对象名称未知。另一个例外是删除集合。
\n
由于您想授予用户创建转发端口的权限,我认为您不能。
\n| 归档时间: |
|
| 查看次数: |
11481 次 |
| 最近记录: |