Home / Knowledge hub / Kubernetes RBAC
Knowledge hub
Kubernetes RBAC
Rules for which accounts and services may do what inside a Kubernetes cluster.
What it means
Kubernetes RBAC, role-based access control, decides which users and service accounts may perform which actions on which cluster resources. A Role lists permitted verbs, such as get, list or delete, on resources such as pods or secrets. A binding then grants that role to someone.
Roles apply within a namespace, while ClusterRoles apply across the cluster. Permissions are only additive: there are no deny rules, so a subject can do anything any of its bindings allows. Granting broadly is easy and taking back is hard to notice.
Why it matters
The cluster's API is the control point for everything running in it. A subject that can read secrets can read database passwords, and one that can create pods may be able to run code on a node. An over-broad binding turns a small compromise into control of the cluster.
Reviewers and customers ask who has administrator rights. RBAC is also where least privilege is actually enforced for clusters, and where privilege escalation starts when it is too loose. Few teams can say, from memory, which of their service accounts can read secrets.
How it shows up
You meet it in role and binding files, in the permissions given to pipelines and operators, and in the service account every pod receives. Repeated mistakes are giving cluster-admin to people or tools for convenience, wildcard verbs and resources, and leaving default service account tokens mounted in pods that never call the API.
Grant narrow roles in the namespace where they are needed, avoid wildcards, review bindings regularly, and disable token mounting where unused. The kubectl auth can-i command shows what a subject may do. Check the permissions of each workload as if it were compromised.
Questions people ask
Kubernetes RBAC, answered
What is the difference between a Role and a ClusterRole?
A Role grants permissions inside one namespace. A ClusterRole can grant permissions across the whole cluster, or to cluster-wide resources such as nodes. A ClusterRole can also be bound within one namespace.
Can Kubernetes RBAC deny access?
No. RBAC rules are purely additive. A subject is allowed an action if any of its roles allows it, so the way to reduce access is to remove or narrow the grants.
Why is cluster-admin dangerous?
It grants all permissions on all resources in the cluster. If a person's account or a pipeline holding it is compromised, the attacker controls everything. Use it rarely and for a short time.
What about service account tokens in pods?
Every pod gets a service account, and by default a token to call the API may be mounted. If the pod does not need the API, turn the mounting off, so a compromised pod has nothing to use.
How do we review our RBAC?
List the bindings, especially ones to cluster-admin, wildcards and the ability to read secrets or create pods. Use kubectl auth can-i to check specific subjects. Remove what is unused, and repeat the review on a schedule.
Sources
Where this comes from
Related
Terms that sit next to this one
Kubernetes
A system that runs and manages containers across many machines.
RBAC
Permissions attach to roles, and people are given roles.
Least privilege
Giving every person and service the minimum access the job requires.
Service account
A non-human identity that software uses to sign in and call other systems.
Kubernetes secrets
Kubernetes objects for passwords and keys, stored encoded but not encrypted by default.
What could one pod's token do?
RBAC mistakes show up when a foothold turns into wider access. Where a finding leads to credentials, we show what they reached and report what we actually exploited. Ask us to run it on one of your applications.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.