All Policies
Restrict Binding to Cluster-Admin
The cluster-admin ClusterRole allows any action to be performed on any resource in the cluster and its granting should be heavily restricted. This policy prevents binding to the cluster-admin ClusterRole in RoleBinding or ClusterRoleBinding resources.
Policy Definition
/other/restrict-binding-clusteradmin/restrict-binding-clusteradmin.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: restrict-binding-clusteradmin
5 annotations:
6 policies.kyverno.io/title: Restrict Binding to Cluster-Admin
7 policies.kyverno.io/category: Security
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: RoleBinding, ClusterRoleBinding, RBAC
10 kyverno.io/kyverno-version: 1.6.2
11 policies.kyverno.io/minversion: 1.6.0
12 kyverno.io/kubernetes-version: "1.23"
13 policies.kyverno.io/description: >-
14 The cluster-admin ClusterRole allows any action to be performed on any resource
15 in the cluster and its granting should be heavily restricted. This
16 policy prevents binding to the cluster-admin ClusterRole in
17 RoleBinding or ClusterRoleBinding resources.
18spec:
19 validationFailureAction: Audit
20 background: true
21 rules:
22 - name: clusteradmin-bindings
23 match:
24 any:
25 - resources:
26 kinds:
27 - RoleBinding
28 - ClusterRoleBinding
29 validate:
30 message: "Binding to cluster-admin is not allowed."
31 pattern:
32 roleRef:
33 name: "!cluster-admin"