← Back to blog

Kubernetes RBAC for Developers: Least-Privilege Access

November 21, 2026
Kubernetes RBAC for Developers: Least-Privilege Access

Developers need to deploy, read logs and debug pods. They do not need to delete nodes or read every Secret in the cluster. Kubernetes RBAC closes that gap: you grant a namespace-scoped Role through a RoleBinding, verify it with kubectl auth can-i, and keep cluster-wide rights for a handful of administrators. Once the rules are in place, a native client such as Kubezilla Desktop lets each developer work inside their granted namespaces from one interface, with kubeconfigs stored locally.

Kubezilla Desktop
Manage Kubernetes Access in One Interface
Use Kubezilla Desktop to connect to clusters and manage resources with locally stored kubeconfigs, live logs and metrics.
Visit

TL;DR

  • RBAC decides what an authenticated user may do: a verb (get, create, delete) on a resource (pods, services), within a namespace or the whole cluster.
  • Give developers a Role plus RoleBinding in their own namespace. Reserve ClusterRoleBindings for cross-namespace or cluster-scoped needs.
  • Avoid wildcards, cluster-admin and the system:masters group for everyday developer work.
  • Treat Secrets access, pods/exec and the right to create workloads as sensitive permissions.
  • Test every change with kubectl auth can-i --as before you hand out the kubeconfig.

Table of Contents

What RBAC controls for a developer

After a request is authenticated, every API call must still pass an authorization check. The RBAC authorizer matches the user or group to permissions, each combining verbs with resources, scoped to a namespace or the cluster. If no rule allows the action, the request is denied. There are no "deny" rules: access is purely additive.

RBAC authorization flow from identity to decision

For a developer, this decides whether kubectl get pods -n payments works, whether logs stream, whether a shell opens in a pod and whether a Deployment can be scaled. It also decides what a GUI client can show, because any client talks to the same API with the same identity.

The four objects you need to know

According to the Kubernetes RBAC reference, there are four objects:

ObjectScopeWhat it does
RoleOne namespaceLists permissions inside that namespace
ClusterRoleCluster-levelLists permissions for cluster-scoped resources, or for namespaced resources in one or all namespaces
RoleBindingOne namespaceGrants a Role or ClusterRole to subjects inside that namespace
ClusterRoleBindingWhole clusterGrants a ClusterRole across every namespace

Two details save a lot of duplication. First, a RoleBinding can reference a ClusterRole, and the permissions then apply only in the binding's namespace. You can define one "developer" ClusterRole and bind it namespace by namespace. Second, a binding's roleRef cannot be changed after creation, so you delete and recreate the binding to point it elsewhere.

Subjects of a binding can be users, groups or ServiceAccounts. Kubernetes does not store user accounts itself, so the identity comes from your authentication method, for example certificates or OIDC. If you are wiring up single sign-on, see our guide on kubeconfig OIDC authentication.

Start from the built-in roles

Kubernetes ships four user-facing ClusterRoles:

  • cluster-admin: any action on any resource.
  • admin: read/write on most namespace resources, including creating roles and role bindings, but no write access to the resource quota or the namespace itself.
  • edit: read/write on most objects, including Secrets, and the ability to run Pods as any ServiceAccount in the namespace.
  • view: read-only, excluding Secrets.

For most developers, edit in their team namespace and view in neighboring ones is a sound starting point. Note that edit includes Secrets. If that is too much for your environment, write a custom Role, as below.

A developer Role in YAML

This example gives a team the common day-to-day rights in a development namespace: manage pods, read logs, open a shell and view Deployments. It follows the pattern in a published access-control walkthrough.

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: development
  name: developer
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "list", "watch", "create", "update", "delete"]
- apiGroups: [""]
  resources: ["pods/log"]
  verbs: ["get"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["create"]
- apiGroups: ["apps"]
  resources: ["deployments"]
  verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: development
  name: developer-binding
subjects:
- kind: Group
  name: team-payments
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: developer
  apiGroup: rbac.authorization.k8s.io

Binding a group rather than individual users means onboarding and offboarding happen in your identity provider, not in dozens of YAML files.

A few rules for writing your own:

  1. Name resources and verbs explicitly. The reference warns that wildcards can grant overly permissive access when new resource types, subresources or custom verbs are added later.
  2. Remember subresources. pods/log and pods/exec are separate from pods. A developer who can list pods but sees a 403 on logs is missing a subresource rule.
  3. Check the API group. Deployments live in apps, core resources such as pods use the empty string.
  4. Split read from write. Give get, list and watch broadly, and create, update, patch and delete narrowly.

Permissions that deserve a second look

Some rights are riskier than they appear. The Kubernetes RBAC good practices page notes:

  • get, list and watch on Secrets reveal their contents.
  • Permission to create workloads implicitly grants access to the Secrets, ConfigMaps and PersistentVolumes a pod can mount, and to the API access of ServiceAccounts in the namespace.
  • Membership in system:masters bypasses all RBAC checks, with superuser access that cannot be revoked. Keep developers out of it.
  • Automatic mounting of ServiceAccount tokens should be avoided where pods do not need it, and the Baseline or Restricted Pod Security Standard is recommended for untrusted principals.

The Securing a Cluster guide adds two traps: a user who cannot create pods directly can still create them by creating a Deployment, and deleting a node through the API terminates and reschedules its pods. Review limited roles with these indirect paths in mind.

The Amazon EKS security workshop makes the same point for pods/exec and pods/attach: they open a shell in any running pod, and the holder inherits that pod's service-account credentials. Grant them only to people whose job needs them, ideally in non-production namespaces.

One safeguard works in your favor: a user can only create or update a role if they already hold every permission it contains at that scope, or have the escalate verb on roles. That is documented for Kubernetes 1.12 and newer. Do not hand out escalate, or bind, casually.

Namespace first, cluster-wide only when necessary

The good practices page recommends assigning permissions at the namespace level where possible, which means RoleBindings over ClusterRoleBindings. A ClusterRoleBinding is justified for things like listing namespaces or reading nodes, which are cluster-scoped. Even there, bind a narrow custom ClusterRole, not cluster-admin.

The CNCF suggests keeping only one or two super-admin users and giving everyone else access to the namespace and resources their application requires. Namespaces are therefore the unit of developer access. Our namespace management guide covers how to structure them, and resource quotas keep one team's workloads from starving another's. Note that the admin role cannot change quotas, which is a useful boundary.

Namespace first, cluster-wide only when necessary

Test before you hand out access

Never assume a binding works. Check it as the subject, using impersonation:

kubectl auth can-i create pods/exec -n development --as=jane --as-group=team-payments
kubectl auth can-i --list -n development --as=jane --as-group=team-payments

The second command lists effective permissions, such as pods with get, list and watch. According to a kubectl RBAC guide, --as relies on API impersonation, so your own identity needs impersonation rights, and for ServiceAccounts it evaluates authorization without testing the token itself.

When a developer reports a 403

Work through it in this order:

  1. Read the error. It names the user, verb, resource and namespace.
  2. Confirm which identity the developer is actually using, since the wrong kubeconfig context is a common cause. Our kubeconfig context management guide covers this.
  3. Run kubectl auth can-i as that identity.
  4. List the RoleBindings and ClusterRoleBindings that reference the subject.
  5. Inspect the rules for the right API group, subresource and namespace.
  6. Re-test after the fix.

On managed clusters, audit logs help too. On GKE, for example, the Admin activity audit log is enabled by default and records an RBAC DENY entry with the user's group memberships when access is refused.

Protecting the credentials that carry the access

RBAC is only as strong as the kubeconfig that presents the identity. A leaked file with a broad role is a leaked cluster, and tight RBAC limits the damage, as the CNCF post points out. Keep kubeconfigs out of chat and repos, prefer short-lived credentials, and read our guides on kubeconfig security and Kubernetes API access security.

Our view

RBAC problems rarely come from the YAML. They come from the daily friction around it. When developers have to juggle several CLI tools, contexts and browser tabs, they ask for broader access just to get unstuck, and that is how cluster-admin ends up in the wrong hands.

We built Kubezilla Desktop around the opposite idea: a native, local-first app where kubeconfigs are stored securely on the machine, with no cloud sync or telemetry. A developer sees the clusters and namespaces their role allows, streams logs, opens pod terminals, edits YAML and scales workloads from one window. Because it uses the identity in the kubeconfig, it works within your RBAC rules rather than around them.

Our advice: design roles per namespace, bind groups, test with can-i, and give developers a client that makes the narrow role comfortable to live with.

Margus

Put narrow roles to daily use

Kubezilla Desktop is a native app for Linux, macOS and Windows with a unified interface for multi-cluster access, SSH tunneling, live logs, metrics, pod terminals, YAML editing, workload scaling, and Helm and Argo CD operations. It is built in Rust for low memory use and fast startup. It costs 5 EUR per month. See the Kubernetes desktop app page to get started.

Kubezilla Desktop

FAQ

Should developers get cluster-admin in a dev cluster?

It is better not to. Cluster-admin allows any action on any resource, including node operations such as draining, as the Helm RBAC documentation notes. The built-in admin or edit role in the developer's namespace covers most development work, and a custom ClusterRole covers the rest.

Which built-in role should I give a developer first?

Use edit in the team's namespace and view elsewhere if they need visibility. Remember that edit can read Secrets. If that is too broad, write a custom Role like the one above.

Can a Role be reused across namespaces?

Not a Role itself, since it is namespaced. Define a ClusterRole once and reference it from a RoleBinding in each namespace. The permissions then apply only in that namespace.

Why can a developer list pods but not read logs?

Logs are the pods/log subresource, and shells are pods/exec. Each needs its own rule. Add the subresource with the minimum verb and re-test with kubectl auth can-i.

Sources