Kubernetes RBAC Cheatsheet

← All cheatsheets
$ kubectl auth can-i --list
BeginnerSecurityUpdated October 2026

Check who can do what, create Roles and bindings, manage service account tokens and audit permissions across the cluster.

Check permissions

kubectl auth whoamiShow who you are logged in as
kubectl auth can-i create deployments -n devCheck one action for yourself
kubectl auth can-i --list -n devList everything you can do in a namespace
kubectl auth can-i --list --as=jane -n devList permissions for another user
kubectl auth can-i get pods --as=system:serviceaccount:dev:app-sa -n devCheck a service account

Create roles and bindings

kubectl create role pod-reader --verb=get,list,watch --resource=pods -n devNamespaced read-only role for pods
kubectl create clusterrole node-reader --verb=get,list,watch --resource=nodesCluster-wide role for nodes
kubectl create rolebinding read-pods --role=pod-reader --user=jane -n devBind a role to a user
kubectl create rolebinding app-read --role=pod-reader --serviceaccount=dev:app-sa -n devBind a role to a service account
kubectl create clusterrolebinding auditors-view --clusterrole=view --group=auditorsGive a group read access everywhere
kubectl auth reconcile -f rbac.yamlApply RBAC files safely

Service accounts

kubectl create serviceaccount app-sa -n devCreate a service account
kubectl create token app-sa -n dev --duration=1hGet a short-lived token
kubectl get serviceaccounts -n devList service accounts

Audit

kubectl get roles,rolebindings -n devList namespaced RBAC objects
kubectl get clusterroles,clusterrolebindingsList cluster RBAC objects
kubectl describe clusterrole adminSee what a role allows
kubectl get clusterrolebindings -o wide | grep cluster-adminFind who has cluster-admin
kubectl get rolebindings -A -o wideList all bindings and subjects

Role and RoleBinding

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: pod-reader
  namespace: dev
rules:
- apiGroups: [""]
  resources: ["pods", "pods/log"]
  verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
  namespace: dev
subjects:
- kind: User
  name: jane
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io