Back to Blog

Kubernetes Authentication & Authorization for the KCSA Exam: Service Accounts, RBAC, Roles & Bindings

A practitioner's guide to how Kubernetes decides who you are and what you can do — the request pipeline from authentication to authorization to admission, user vs service account identity, and the RBAC objects (Roles, ClusterRoles, RoleBindings, ClusterRoleBindings) the KCSA exam tests.

By Sailor Team , August 27, 2026

Every request that reaches a Kubernetes cluster has to answer two questions before anything happens: who are you? and what are you allowed to do? The first is authentication, the second is authorization, and the KCSA exam expects you to keep them straight, to know which mechanism handles each, and to be able to read a small RBAC rule and predict whether a given action is allowed or denied. This is one of the most testable areas in the exam’s Kubernetes Security Fundamentals domain because the objects are concrete, the logic is deterministic, and a single wrong assumption — like thinking a Role can grant cluster-wide access — flips the answer.

This guide walks the full request pipeline, separates human users from service accounts, and then works through the four RBAC objects — Role, ClusterRole, RoleBinding, and ClusterRoleBinding — with the exact rules that separate them. We finish with a decision table, kubectl commands you can run to reason about access, and an FAQ. If you are still building your study plan, pair this with the KCSA study plan and the KCSA exam guide for 2026.

Why Access Control Dominates KCSA Security Fundamentals

The KCSA is a conceptual, multiple-choice exam — you are not asked to write manifests under time pressure, you are asked to reason about security behavior. Access control is ideal material for that format because it is rule-based. A question can show you a RoleBinding in the dev namespace and ask whether the bound subject can list secrets in prod; the answer follows mechanically from the rules if you know them, and is a coin-flip if you don’t.

Access control also sits at the center of the cluster component security picture. The API server is the single front door to the cluster, and RBAC is the lock on that door. Understanding it is a prerequisite for the Kubernetes threat model, where over-permissioned identities are one of the most common paths an attacker uses to escalate from a single compromised Pod to full cluster control.

The Request Pipeline: Authentication, Authorization, Admission

Every call to the Kubernetes API server — whether from kubectl, a controller, or a Pod using the client library — passes through three stages in a fixed order. Knowing the order, and what each stage can and cannot do, is a recurring KCSA test point.

StageQuestion it answersOutcome
AuthenticationWho is making this request?Establishes identity, or rejects as anonymous
AuthorizationIs this identity allowed to perform this action?Allow or deny the specific verb on the resource
Admission controlShould this allowed request be modified or further validated?Mutate, validate, or reject before persistence

The critical exam nuance: authentication only establishes identity — it never grants any permission. A perfectly authenticated user with no authorization rules can do nothing. Conversely, authorization assumes identity is already known; it cannot inspect credentials. Admission control runs after a request is both authenticated and authorized, and is where policies like Pod Security Admission enforce workload constraints. Get an action wrong at any stage and the request stops there.

Authentication: How Kubernetes Establishes Identity

Kubernetes does not have a built-in user database. There is no kubectl create user. Instead, the API server is configured with one or more authentication modules, and it tries each until one produces an identity. The KCSA wants you to recognize the common methods and, more importantly, the distinction between the two kinds of identity.

Human users are authenticated by mechanisms external to the cluster:

  • X.509 client certificates — a certificate signed by the cluster CA; the Common Name becomes the username and Organization fields become groups.
  • OpenID Connect (OIDC) tokens — issued by an external identity provider, the standard approach for enterprise SSO.
  • Authenticating proxies and webhook token authentication — delegate the decision to an external service.

The key fact: users are not Kubernetes objects. You cannot kubectl get users. Identity is asserted by an external system and merely recognized by the API server. This is why user management is an operational concern handled outside the cluster.

Service accounts, by contrast, are Kubernetes objects, managed by the API and scoped to a namespace. They exist to give in-cluster workloads an identity, and they are the identity type you will manipulate most often.

Service Accounts: Identity for Workloads

A ServiceAccount is the identity a Pod uses to talk to the API server. When you create a Pod without specifying one, it is assigned the default service account in its namespace. The API server issues a short-lived, automatically-rotated bound token (a JWT) and mounts it into the Pod at a well-known path, so the application inside can present it on every API call.

# Create a dedicated service account for a workload
kubectl create serviceaccount log-reader -n monitoring

# Reference it in the Pod spec so the workload uses that identity
apiVersion: v1
kind: Pod
metadata:
  name: log-collector
  namespace: monitoring
spec:
  serviceAccountName: log-reader
  automountServiceAccountToken: true
  containers:
    - name: collector
      image: example/collector:1.0

Two facts the KCSA repeatedly tests:

  1. The default service account should not be granted permissions. Every Pod that does not specify a service account inherits default; binding roles to it silently over-permissions unrelated workloads. Best practice is a dedicated, minimally-scoped service account per workload.
  2. Set automountServiceAccountToken: false when a workload does not call the API. A mounted token is a credential; a compromised container with an unused token still hands an attacker an identity to probe with. Disabling the automount removes that credential from the blast radius — a direct application of least privilege and a favorite exam detail.

Service accounts answer who a workload is. RBAC answers what that identity may do.

Authorization Modes: Where RBAC Fits

After authentication, the API server evaluates the request against its configured authorization modules. Several exist — Node (authorizes kubelet requests), ABAC (attribute-based, file-driven, largely legacy), Webhook (delegates to an external service), and RBAC (Role-Based Access Control). Modern clusters run RBAC as the primary mode, and it is the one the KCSA focuses on.

Authorization in Kubernetes is additive and default-deny. There are no “deny” rules in RBAC. A request is denied unless some rule explicitly allows it, and if any authorizer in the chain allows the request, it proceeds. This means you grant access by adding permissive rules, and you restrict access by not granting them — you never write an explicit deny. Understanding “default-deny, allow-only, additive” is essential: a question that shows two bindings and asks what a subject can do is really asking you to take the union of their allowed verbs.

The Four RBAC Objects

RBAC is built from exactly four object types, split along a single axis — namespaced vs. cluster-scoped — crossed with permissions vs. binding.

ObjectScopePurpose
RoleSingle namespaceDefines a set of permissions (verbs on resources) within one namespace
ClusterRoleCluster-wideDefines permissions cluster-wide or for cluster-scoped resources
RoleBindingSingle namespaceGrants a Role or a ClusterRole to subjects, effective in one namespace
RoleBinding / ClusterRoleBinding—Connects subjects (users, groups, service accounts) to a role
ClusterRoleBindingCluster-wideGrants a ClusterRole to subjects across all namespaces

Think of it as two halves: Roles and ClusterRoles define permissions but grant nothing; RoleBindings and ClusterRoleBindings grant those permissions to subjects. A Role by itself is inert — it is a named list of allowed actions that does nothing until a binding attaches a subject to it.

Role: Permissions Inside One Namespace

A Role is a namespaced object. Every permission it defines applies only within its own namespace. Each rule combines apiGroups, resources, and verbs (like get, list, watch, create, update, delete).

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: dev
  name: pod-reader
rules:
  - apiGroups: [""]          # "" is the core API group
    resources: ["pods"]
    verbs: ["get", "list", "watch"]

This Role permits reading Pods in the dev namespace only. It grants nothing in prod, and it cannot grant access to cluster-scoped resources like nodes or namespaces — those simply cannot appear in a Role.

ClusterRole: Cluster-Wide Permissions

A ClusterRole is not namespaced. It exists for three cases the KCSA expects you to name:

  • Permissions on cluster-scoped resources — nodes, persistent volumes, namespaces themselves.
  • Permissions on non-resource URLs — endpoints like /healthz.
  • Permissions on namespaced resources across all namespaces — for example, “read secrets in every namespace.”
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: node-viewer
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]

Because nodes are cluster-scoped, this permission is impossible to express in a Role — it must be a ClusterRole.

RoleBinding and ClusterRoleBinding: Granting the Permissions

A binding connects a role to subjects — users, groups, or service accounts. The scope of the binding determines where the permissions take effect, and this is the single most important — and most tested — subtlety in Kubernetes RBAC.

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
  namespace: dev
subjects:
  - kind: ServiceAccount
    name: log-reader
    namespace: dev
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io

A ClusterRoleBinding grants a ClusterRole across the entire cluster:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: view-nodes-cluster-wide
subjects:
  - kind: ServiceAccount
    name: monitoring-agent
    namespace: monitoring
roleRef:
  kind: ClusterRole
  name: node-viewer
  apiGroup: rbac.authorization.k8s.io

The One Combination That Trips Everyone Up

The KCSA loves this scenario: a RoleBinding that references a ClusterRole. It is legal and useful, and its behavior is precise.

When a RoleBinding references a ClusterRole, the permissions in that ClusterRole are granted only within the RoleBinding’s namespace — not cluster-wide. The ClusterRole acts as a reusable template of permissions, and the namespaced RoleBinding scopes them down to a single namespace.

This gives you a pattern worth memorizing: define a common permission set once as a ClusterRole (say, secret-reader), then attach it to different service accounts in different namespaces with separate RoleBindings — each grant confined to its own namespace. The scoping is determined by the binding, never by the role.

Contrast the two failure-mode answers the exam sets up:

  • A RoleBinding → ClusterRole grants the ClusterRole’s permissions in one namespace only.
  • A ClusterRoleBinding → ClusterRole grants them in every namespace.

Confusing these is the difference between a scoped read grant and accidentally letting a monitoring agent read every secret in the cluster.

Reasoning About Access with kubectl auth can-i

You do not have to trace bindings by hand. The kubectl auth can-i command evaluates the full authorization chain and answers yes or no, and it is the practical tool the exam’s mindset rewards.

# Check your own access
kubectl auth can-i list secrets -n prod

# Check what a specific service account can do (impersonation)
kubectl auth can-i get pods \
  --as=system:serviceaccount:monitoring:log-reader -n monitoring

# List every action you are allowed to take in a namespace
kubectl auth can-i --list -n dev

Using --as to impersonate a service account is how you verify least privilege: after granting a role, confirm the subject can do exactly what it needs and nothing more. If can-i get secrets returns yes for a workload that only reads Pods, you have found an over-grant.

Least Privilege: The Principle Behind Every RBAC Question

The KCSA frames RBAC through the lens of least privilege — every identity should have the minimum permissions required, and no more. Translated into concrete rules the exam rewards:

  • Prefer Roles over ClusterRoles. Namespace-scoped grants contain the blast radius; reach for cluster-wide permissions only when the resource is genuinely cluster-scoped.
  • Avoid wildcards. verbs: ["*"] or resources: ["*"] grants far more than any real workload needs and turns a compromised token into cluster-wide power.
  • Never bind to the default service account. Give each workload its own.
  • Do not hand out cluster-admin. The built-in cluster-admin ClusterRole allows every action on every resource; a ClusterRoleBinding to it is effectively root on the cluster.
  • Audit regularly. ClusterRoleBindings and any binding to cluster-admin are the first things to review, because they have the widest reach.

This connects directly to the 4Cs of cloud native security: RBAC is a core control at the Cluster layer, and a least-privilege posture there limits how far an attacker who breaches the Container layer can move.

Putting It Together: A Decision Table

You need to…Use
Allow reading Pods in one namespaceRole + RoleBinding
Allow reading nodes (cluster-scoped)ClusterRole + ClusterRoleBinding
Reuse one permission set across namespaces, scoped per namespaceClusterRole + a RoleBinding in each namespace
Grant a permission in every namespaceClusterRole + ClusterRoleBinding
Give a workload an identity to call the APIServiceAccount referenced in the Pod spec
Prove an identity has exactly the access intendedkubectl auth can-i --as=... --list

Practicing Under Exam Conditions

Reading RBAC rules and answering timed scenario questions are different skills. The rules above are deterministic, but the KCSA phrases them as short scenarios with plausible distractors — a RoleBinding that references a ClusterRole, a subject that inherits default, a wildcard verb hiding an over-grant. The way to make the logic automatic is to see it repeatedly in question form and check your reasoning against explanations.

That is exactly what Sailor.sh’s KCSA mock exam bundle is built for. Each mock mirrors the real exam’s format and difficulty, with detailed explanations for every option so you learn why a RoleBinding-to-ClusterRole grant is namespace-scoped, not just that it is. Used alongside the free KCSA practice questions and the security fundamentals guide, it turns access control from a topic you recognize into one you can answer on reflex.

Frequently Asked Questions

What is the difference between authentication and authorization in Kubernetes?

Authentication establishes who is making a request — it produces an identity (a username and groups, or a service account) or rejects the request as anonymous. Authorization decides what that already-identified subject may do. Authentication never grants permissions, and authorization never inspects credentials; they are separate, sequential stages, with authentication first.

Can a Role grant access to cluster-scoped resources like nodes?

No. A Role is namespaced and can only reference namespaced resources within its own namespace. Cluster-scoped resources such as nodes, persistent volumes, and namespaces can only be granted through a ClusterRole. Attempting to list them in a Role is a common wrong-answer trap.

What happens when a RoleBinding references a ClusterRole?

The ClusterRole’s permissions are granted only within the RoleBinding’s namespace, not cluster-wide. The ClusterRole acts as a reusable permission template, and the namespaced RoleBinding scopes it down. To grant the same ClusterRole everywhere, you would use a ClusterRoleBinding instead.

Why should the default service account not be given permissions?

Every Pod that does not specify a service account is automatically assigned the default service account in its namespace. Binding roles to default therefore grants those permissions to unrelated workloads that never asked for them, violating least privilege. Best practice is a dedicated service account per workload and leaving default unprivileged.

Does RBAC support explicit deny rules?

No. RBAC is additive and default-deny: every action is denied unless some rule explicitly allows it, and there is no way to write a deny rule. You restrict access by not granting it. When multiple bindings apply to a subject, its effective permissions are the union of all allowed verbs.

How can I check what a service account is allowed to do?

Use kubectl auth can-i with impersonation, for example kubectl auth can-i get pods --as=system:serviceaccount:monitoring:log-reader -n monitoring, or list everything with kubectl auth can-i --list --as=.... This evaluates the full authorization chain and is the standard way to verify a least-privilege configuration.

Conclusion

Kubernetes access control is one of the most answerable topics on the KCSA precisely because it is rule-driven. Fix the pipeline in your mind — authenticate, then authorize, then admit — remember that authentication only names you while authorization decides what you can do, and internalize the namespaced-vs-cluster-scoped split across Roles, ClusterRoles, and their bindings. The one subtlety worth over-learning is that a RoleBinding to a ClusterRole is namespace-scoped, because that single fact resolves a large share of the trickier questions. Layer least privilege on top — dedicated service accounts, no wildcards, no gratuitous cluster-admin — and you will read these scenarios the way the exam intends: as deterministic puzzles with exactly one correct answer.

When you are ready to test that reflex under realistic conditions, work through the KCSA mock exam bundle and revisit the KCSA exam guide for 2026 to keep the rest of the domains sharp.

Limited Time Offer: Get 80% off all Mock Exam Bundles | Sale ends in 7 days. Start learning today.

Claim Now