Skip to content

Kubernetes RBAC (Role / ClusterRole / RoleBinding / ClusterRoleBinding) ​

Kubernetes RBAC (Role-Based Access Control) objects define "who can do what on which resources" inside a cluster, enforced by the kube-apiserver. This page covers the four objects under Cluster Resources → Kubernetes RBAC in Kuboard:

ResourceScopePurposeTypical use
RoleNamespaceDefines a set of permissions within one namespaceA "workloads read-write" role for a team inside a namespace
ClusterRoleClusterDefines a set of permissions cluster-wide or across namespacesCluster admin, read-only nodes, CRD management
RoleBindingNamespaceBinds a Role or ClusterRole to subjects, effective only in that namespaceBind the "dev role" above to a user
ClusterRoleBindingClusterBinds a ClusterRole to subjects, effective cluster-wideBind "cluster read-only" to all authenticated users

Subjects can be a user (User), a group (Group) or a service account (ServiceAccount); after binding, the apiserver authorizes based on the role's rules (apiGroups / resources / verbs). Kuboard provides full list / detail / create / edit / delete for all four.

Difference from Kuboard's own authorization model

This menu manages access control inside the Kubernetes cluster, which is fully independent from Kuboard's own authorization (user → group → role → binding scope, see Authorization Scopes). Platform authorization controls "who can log in to Kuboard and which clusters / namespaces they see"; Kubernetes RBAC controls "what a user can do with cluster resources". The two are usually used together.

Entry ​

Cluster Resources → Kubernetes RBAC, split into four lists: Roles / Role Bindings / Cluster Roles / Cluster Role Bindings. The lists, details, create and edit pages all reuse the generic resource pages (see Resource List Pages and Resource Detail Pages).

Data channel

Roles and Role Bindings are cache-synced (roughly every 5 seconds) and support pagination. Cluster Roles and Cluster Role Bindings are not cached — the list queries the cluster API directly, so the data is real-time but cannot be paginated.

Create a Role / ClusterRole ​

  1. Go to Cluster Resources → Kubernetes RBAC → Roles (or Cluster Roles), click Create, choose Create from form;
  2. Fill in the form:
AreaFieldDescription
MetadataNameRequired. Role: a DNS label (lowercase letters / digits / - / ., max 63 chars). ClusterRole: a DNS subdomain (max 253 chars)
LabelsOptional key/value pairs
Rules rules[]API groupse.g. (core), apps, batch; multiple allowed; * = all API groups
Resourcese.g. pods, deployments; multiple allowed; * = all resources
Verbse.g. get / list / watch / create / update / delete / patch; multiple allowed; * = all verbs

E.g. read-only Pods: API group (core), resources pods, verbs get / list / watch. Click + Add to append more rules (rules are OR'ed — any match grants).

  1. Click Save, confirm in the Preview YAML, then submit.
sh
kubectl get roles -A            # list Roles across all namespaces
kubectl get clusterroles        # list Cluster Roles

Create a RoleBinding / ClusterRoleBinding ​

  1. Go to Cluster Resources → Kubernetes RBAC → Role Bindings (or Cluster Role Bindings), click Create, choose Create from form;
  2. Fill in the form:
AreaFieldDescription
MetadataNameRequired
NamespaceThe namespace where the binding applies (read-only); Cluster Role Bindings are cluster-scoped and omit this
Subjects subjects[]KindUser / Group / ServiceAccount
NameThe subject name, e.g. alice, dev-team, my-sa
NamespaceThe service account's namespace (when subject kind is ServiceAccount)
Role reference roleRefRole kindRole or ClusterRole
Role nameThe referenced role name
  1. Click Save, confirm in the Preview YAML, then submit.

The role kind decides the effect scope

  • A RoleBinding can reference a Role in the same namespace, or a ClusterRole (the permissions then take effect within that namespace only);
  • A ClusterRoleBinding can only reference a ClusterRole, and takes effect across the whole cluster — make sure that is the granularity you want.

Security assessment on the list ​

The binding list flags high-risk bindings directly (expand a row to see subject details and the role reference):

FlagMeaning
Anonymous accessThe binding includes system:anonymous / system:unauthenticated subjects, allowing anonymous or unauthenticated access — extremely risky; consider removing
All authenticated accessThe binding includes system:authenticated, so every authenticated user in the cluster can access — consider narrowing to an explicit subject list
Cluster-scope warningA ClusterRoleBinding applies to the whole cluster; keep the binding as small as possible

Verify ​

After saving, authorization is enforced immediately by the kube-apiserver (Kuboard only writes the objects; it does not intercept). Use the commands below to double-check the expected result:

sh
kubectl auth can-i --as=alice get pods -n dev
kubectl auth can-i --as=alice list deployments -n dev