Description
Review which accounts receive cluster-admin through a ClusterRoleBinding. It gives those accounts control over resources and permissions throughout the cluster.
Potential impact
A compromised administrator account or an accidental deletion can affect resources across namespaces.
Remediation
- Identify the operations and namespaces each account needs. For read-only access, choose
viewor a role limited to the required resources. Use aRoleBindingfor access within a single namespace. - Preserve required administrator access while preparing the replacement binding. The existing binding’s
roleRefis immutable. Remove the unneeded administrative binding, then verify the account’s effective permissions.
Examples
These historical examples use the Helm 2 tiller service account in the kube-system namespace.
Before
yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-binding
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
After
yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: view-binding
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
roleRef:
kind: ClusterRole
name: view
apiGroup: rbac.authorization.k8s.io
The separate view-binding grants read access across the cluster. If admin-binding remains, tiller still has administrator access.