我已经为命名空间上的所有服务帐户(包括命名空间本身)设置了删除限制(使用验证webhook),作为集群管理员,有没有办法我可以从该命名空间中删除对象?
package kubernetes.admission
deny[msg] {
namespace := input.request.namespace
operation := input.request.operation
namespaces := {"test01"}
operations := {"CREATE","DELETE","UPDATE"}
namespaces[namespace]
operations[operation]
msg := sprintf("Operation not permitted in protected namespace, invalid operation for %q",[namespace,operation])
}
或者,是否可以将集群管理员置于例外状态。
更新:
我想出了要执行的用户名,但是此策略虽然在策略检查器中可以正确评估,但没有状态:configmap状态为ok:
package kubernetes.admission
deny[msg] {
namespace := input.request.namespace
operation := input.request.operation
username := input.request.userInfo.username
namespaces := {"test01","kube-system"}
users := {"kubernetes-admin","admin"}
operations := {"CREATE","DELETE","UPDATE"}
namespaces[namespace]
operations[operation]
not users[username]
msg := sprintf("Operation not permitted in protected namespace, invalid operation for %q",[namespace,username,operation])
}
并且除非您想直接针对ETCD进行操作,否则无法绕过API服务器,这将是灾难恕我直言