Kubernetes Role is a namespaced RBAC object that defines which actions are allowed on Kubernetes resources inside one namespace. In practical terms, a Role can say that a user, service account, or group may read Pods, update ConfigMaps, or manage Jobs in a specific namespace, but it does nothing until you attach it with a RoleBinding.
A Role is part of Kubernetes RBAC, which stands for Role-Based Access Control. RBAC controls access to the Kubernetes API by checking whether a subject is allowed to perform a verb on a resource.
A Role answers questions such as:
payments namespace?staging namespace?Roles help you give teams and automation the minimum permissions they need inside a namespace, without granting wider cluster access.
A Role contains one or more policy rules. Each rule defines:
apps for Deployments or an empty string for core resources like Pods and Services.pods, deployments, configmaps, or secrets.get, list, watch, create, update, patch, or delete.After you create a Role, you bind it to a subject with a RoleBinding. The subject can be a Kubernetes ServiceAccount, an authenticated user, or a group.
This Role allows read-only access to Pods in a namespace:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: staging
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
On its own, this Role grants nothing. You need a RoleBinding like this:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: staging
name: read-pods-for-ci
subjects:
- kind: ServiceAccount
name: ci-runner
namespace: staging
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
With both objects in place, the ci-runner service account can read Pods in the staging namespace, but it cannot modify them and cannot access Pods in other namespaces.
A Role is limited to one namespace. A ClusterRole is cluster-scoped.
dev, staging, or payments.For most application team access, start with a Role. Move to ClusterRole only when the permission truly needs cluster-level scope.
If you manage Kubernetes access through infrastructure code, you can define Roles and RoleBindings alongside your workloads. For example, teams often manage RBAC together with manifests when they deploy Kubernetes resources using Terraform.
resources: ["*"] and verbs: ["*"] are hard to control over time.Assume a startup runs one shared EKS cluster with separate namespaces for frontend, backend, and data. The backend team needs to restart Deployments and inspect logs in the backend namespace, but should not access the data namespace.
You can create a Role in the backend namespace that allows:
get, list, and watch on Podsget on Pod logsget, list, watch, and patch on DeploymentsThen you bind that Role to the backend team’s Kubernetes group. The team can debug and restart its own services without gaining broad production access.
kubectl auth can-i to test permissions before giving access to users or automation.For example:
kubectl auth can-i list pods \
--as=system:serviceaccount:staging:ci-runner \
--namespace=staging
This command checks whether the ci-runner service account can list Pods in the staging namespace.
Roles are a core part of secure Kubernetes operations. Whether you are deploying application workloads, running controllers, or managing cloud resources through Kubernetes tools such as Crossplane, clear RBAC boundaries help keep access predictable. If your platform team is building Kubernetes-driven infrastructure workflows, the same access patterns apply when you deploy AWS resources using Crossplane on Kubernetes.