我有两个PodSecurityPolicy:
我对他们分配豆荚有问题。
第一项政策约束力:
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: psp:privileged
rules:
- apiGroups:
- extensions
resources:
- podsecuritypolicies
resourceNames:
- 000-privileged
verbs:
- use
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: psp:privileged-kube-system
namespace: kube-system
subjects:
- kind: Group
name: system:serviceaccounts
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: psp:privileged
apiGroup: rbac.authorization.k8s.io第二项政策约束力:
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: psp:restricted
rules:
- apiGroups:
- extensions
resources:
- podsecuritypolicies
resourceNames:
- 100-restricted
verbs:
- use
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: psp:restricted
subjects:
- kind: Group
name: system:authenticated
apiGroup: rbac.authorization.k8s.io
- kind: Group
name: system:serviceaccounts
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: psp:restricted
apiGroup: rbac.authorization.k8s.io库贝系统一切正常。
但是,在其他名称空间中,它不像预期的那样工作:
我的kubectl配置了来自OpenID连接(OIDC)的外部身份验证令牌。
我验证了访问权限,一切看起来都很好:
kubectl auth can-i use psp/100-restricted
yes
kubectl auth can-i use psp/000-privileged
no有线索吗?
发布于 2019-08-30 15:45:09
问题是,我的用户可以访问apiGroup的角色中所有资源(*)的所有谓词(*)。
文档有点不清楚(https://github.com/kubernetes/examples/tree/master/staging/podsecuritypolicy/rbac):
use谓词是一个特殊的动词,它授予对使用策略的访问权,而不允许任何其他访问。请注意,在名称空间中具有超级用户权限的用户(访问*资源上的*谓词)将被允许使用该名称空间中的任何PodSecurityPolicy。
提到“在那个名称空间中”,我感到很困惑。因为PodSecurityGroup不是“名称空间”,所以我认为如果没有在名称空间中提供显式访问的集群could /RoleBinding,就无法使用它们。看来我错了..。
我修改了角色以指定以下内容:
rules:
- apiGroups: ["", "apps", "autoscaling", "batch"]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["extensions"]
resources: ["*"]
# Avoid using * here to prevent use of 'use' verb for podsecuritypolicies resource
verbs: ["create", "get", "watch", "list", "patch", "delete", "deletecollection", "update"]现在它找到了合适的PSP。有趣的是,它还阻止用户修改(create/delete/update/etc) podsecuritypolicies。
似乎“使用”动词毕竟是很特别的……
https://stackoverflow.com/questions/57720681
复制相似问题