Skip to content

Authorization: KCSA practice questions

After the API server has authenticated a request, an authorizer decides whether that identity may perform the requested verb on the requested resource. Kubernetes supports several authorization modes, including Node, RBAC, ABAC and Webhook, plus AlwaysAllow and AlwaysDeny, which are meant only for testing.

By Ibrahim Yesilay · Published · Updated

Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.

What Authorization covers in KCSA

After the API server has authenticated a request, an authorizer decides whether that identity may perform the requested verb on the requested resource. Kubernetes supports several authorization modes, including Node, RBAC, ABAC and Webhook, plus AlwaysAllow and AlwaysDeny, which are meant only for testing. AlwaysAllow is dangerous on any reachable cluster, and because RBAC has no deny rules, a configuration such as AlwaysAllow,RBAC behaves exactly like AlwaysAllow.

Role-based access control is the mode most clusters rely on. A Role or ClusterRole holds rules, each a combination of API groups, resources and verbs such as get, list, watch, create, update and delete. Permissions are purely additive; there is nothing to subtract. A Role always belongs to one namespace, while a ClusterRole is not namespaced and can describe cluster-scoped resources, non-resource endpoints, or namespaced permissions meant for reuse across namespaces. The kubectl helper for a namespaced read-only role looks like kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods.

Bindings attach roles to subjects, which are users, groups or ServiceAccounts. A RoleBinding grants permissions inside its own namespace and can reference either a Role in that namespace or a ClusterRole; in the second case the ClusterRole's rules apply only within the binding's namespace. A ClusterRoleBinding grants access across the whole cluster. This distinction matters for the cluster-admin ClusterRole: bound with a ClusterRoleBinding it gives full control of every resource in every namespace, while bound with a RoleBinding it gives full control of everything in that one namespace, including the namespace itself. Binding a role to the group system:authenticated hands it to every authenticated user, and the documentation warns that binding cluster-admin to all service accounts lets any container act as a cluster administrator. A binding's roleRef cannot be changed after creation; to switch roles you delete and recreate the binding.

RBAC also prevents privilege escalation through its own API. You can create or update a role only if you already hold every permission it contains, at the same scope, or if you have the escalate verb on roles or clusterroles. Similarly, creating a binding requires holding the referenced permissions or the bind verb. Wildcards in resources or verbs are risky because they automatically include resource types and subresources added later.

To check effective permissions, kubectl auth can-i asks the authorizer directly, and administrators can combine it with --as to test another user or a ServiceAccount such as system:serviceaccount:dev:dev-sa. Authorization limits what an identity may do, not how much it may consume; per-namespace consumption limits come from a ResourceQuota, which caps aggregate resource usage and object counts in a namespace.

Key points

  • A RoleBinding that references a ClusterRole grants those permissions only in the binding’s namespace.
  • RBAC rules only grant access; there are no deny rules.
  • Creating a role needs all of its permissions already, or the escalate verb.
  • roleRef is immutable: changing the role means replacing the binding.
  • ResourceQuota limits consumption per namespace; it is not an authorization mechanism.

Three sample questions

15 KCSA questions on Authorization, 15 with explanations. How practice works

Question 1

In Kubernetes RBAC, what does a Role define?
  1. A.A set of users and their passwords
  2. B.Permissions within a namespace
  3. C.Network policies for pods
  4. D.Global cluster-wide permissions
  5. E.Resource quotas for a project

Correct answer: B

A Role in Kubernetes RBAC defines a set of permissions that are applicable within a specific namespace. This allows for fine-grained control over resources within that namespace.

Sources: Kubernetes RBAC Documentation, RBAC Roles and RoleBindings

Question 2

If a user is granted the 'cluster-admin' ClusterRole through a RoleBinding, what level of access will they have?
  1. A.Full administrative privileges limited to the namespace where the RoleBinding is applied
  2. B.Full cluster-wide administrative privileges
  3. C.Read-only access to all resources in the cluster
  4. D.No permissions; ClusterRoles require ClusterRoleBindings to take effect
  5. E.Access only to service accounts within the namespace

Correct answer: A

When a ClusterRole, such as 'cluster-admin', is assigned using a RoleBinding, it grants full administrative privileges but only within the namespace where the RoleBinding is applied. This is because RoleBindings are namespace-scoped, meaning they cannot grant cluster-wide permissions even if the associated role is a ClusterRole. To grant cluster-wide permissions, a ClusterRoleBinding must be used. Incorrect options: (1) Full cluster-wide privileges require a ClusterRoleBinding, not a RoleBinding. (2) Read-only access is not tied to this scenario. (3) The statement about 'no permissions' is incorrect because RoleBindings do apply within their namespace. (4) Access to service accounts is not exclusive in this context.

Sources: Kubernetes Official Documentation - RBAC, StrongDM Blog - Kubernetes RBAC Explained

Question 3

In Kubernetes Role-Based Access Control (RBAC), what is the purpose of a RoleBinding?
  1. A.Defines permissions within a namespace
  2. B.Associates a Role with users, groups, or service accounts within a namespace
  3. C.Creates a new role with cluster-wide permissions
  4. D.Manages network policies for a namespace
  5. E.Sets resource quotas for a project

Correct answer: B

A RoleBinding in Kubernetes RBAC binds a Role to one or more subjects (users, groups, or service accounts) within a specific namespace, granting them the permissions defined in that Role. Roles themselves define permissions, but RoleBindings associate those permissions with subjects. ClusterRoles and ClusterRoleBindings are used for cluster-wide permissions. Network policies and resource quotas are managed by different Kubernetes objects unrelated to RoleBindings.

Sources: Kubernetes Official Documentation - Using RBAC Authorization, Kubernetes RBAC Concepts

Practice this topic

Focus mode keeps every question on Authorization until you leave it. 10 free guest answers, then a free account; no credit card.

Or open KCSA practice across all topics.

Sources

The explanation above was checked against these official documents.