Kubectl RBAC

Least-privilege access with Roles, bindings, and auth checks.

  • kubernetes rbac
  • rolebinding
  • serviceaccount
  • can-i
  • least privilege

Kubectl RBAC

Least-privilege access with Roles, bindings, and auth checks.

Commands

CommandWhat it does
kubectl auth can-i list pods --as=dev:aliceTest someone's permission
kubectl get roles,rolebindings -AAudit namespaced grants
`kubectl get clusterroleshead`Cluster-wide roles
kubectl create role pod-reader --verb=get,list --resource=podsMinimal read role
kubectl describe rolebinding pod-readersWho holds the grant

Example

kubectl auth can-i delete deploy --as=dev:alice --namespace=shop
kubectl create role pod-reader --verb=get,list --resource=pods -n shop

FAQ

Role vs ClusterRole?

Role is namespace-scoped; ClusterRole grants cluster-wide or spans namespaces when bound with a ClusterRoleBinding.

How do CI bots authenticate?

ServiceAccounts with a dedicated RoleBinding โ€” never share admin kubeconfigs with automation.

Soalan Lazim

Role vs ClusterRole?
Role is namespace-scoped; ClusterRole grants cluster-wide or spans namespaces when bound with a ClusterRoleBinding.
How do CI bots authenticate?
ServiceAccounts with a dedicated RoleBinding โ€” never share admin kubeconfigs with automation.

Kubernetes