Review Kubernetes cluster-admin binding permissions

Grant cluster-wide administrative permissions only to identities that need them.

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

  1. Identify the operations and namespaces each account needs. For read-only access, choose view or a role limited to the required resources. Use a RoleBinding for access within a single namespace.
  2. Preserve required administrator access while preparing the replacement binding. The existing binding’s roleRef is 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.

References