Study guide
2.4 Role-Based Access Control (RBAC): Roles & RoleBindings
Certified Kubernetes Administrator CKA
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: CKA Exam Environment & Cluster Architecture
1.1 CKA Exam Mechanics, Scoring & Remote Terminal Environment 1.2 Kubernetes Control Plane & Worker Node Components 1.3 etcd Architecture, Clustering & Raft Consensus 1.4 Initializing Clusters with Kubeadm 1.5 Highly Available (HA) Control Plane Topologies 1.6 Cluster Lifecycle & Step-by-Step Upgrades 1.7 etcd Snapshot Backup and Restore Procedures
2 Chapter 2: Cluster Extensions, Packaging & RBAC
2.1 Kubernetes TLS Certificates & PKI Infrastructure 2.2 Managing Kubeconfig Files, Users, & Contexts 2.3 Installing Cluster Components with Helm & Kustomize 2.4 Role-Based Access Control (RBAC): Roles & RoleBindings 2.5 ClusterRoles & ClusterRoleBindings 2.6 Custom Resource Definitions (CRDs) & Operators 2.7 Pod Security Standards (PSS) & Admission Controllers
3 Chapter 3: Workloads, Lifecycle & Pod Scheduling
3.1 Pod Lifecycle, Multi-Container Patterns & Init Containers 3.2 Deployments: Rolling Updates, Rollouts & Rollbacks 3.3 DaemonSets & StatefulSets Architecture 3.4 Batch Workloads: Jobs & CronJobs 3.5 Managing ConfigMaps & Sensitive Data with Secrets 3.6 Resource Requests, Limits & Namespace ResourceQuotas 3.7 NodeSelectors, Node Affinity & Anti-Affinity 3.8 Node Taints & Pod Tolerations 3.9 Autoscaling: Horizontal Pod Autoscaler (HPA) & Custom Metrics
4 Chapter 4: Services, Networking & Ingress Architecture
4.1 Kubernetes IP-per-Pod Model & CNI Plugins (Flannel, Calico, Cilium) 4.2 Services Deep Dive: ClusterIP, NodePort, LoadBalancer & EndpointSlices 4.3 Kube-Proxy Service Dataplane: iptables, nftables, IPVS & eBPF 4.4 CoreDNS Configuration, Resolution & Custom Forwarding 4.5 NetworkPolicies: Ingress, Egress & Default-Deny Isolation 4.6 Ingress Architecture, Controllers & Path-Based Routing 4.7 Gateway API: GatewayClass, Gateway, HTTPRoute & Traffic Splitting 4.8 External Traffic Ingress: NodePort, Cloud LoadBalancers & MetalLB
5 Chapter 5: Storage Architecture & Persistent Volumes
5.1 Ephemeral Volumes, EmptyDir, HostPath & Config Volumes 5.2 PersistentVolumes (PV) & PersistentVolumeClaims (PVC) Lifecycle 5.3 StorageClasses, Dynamic Provisioning & VolumeBindingModes 5.4 Storage Access Modes, Reclaim Policies & Volume Expansion 5.5 Container Storage Interface (CSI) Architecture & Drivers 5.6 StatefulSet VolumeClaimTemplates & Persistent Storage Workflows
6 Chapter 6: Advanced Troubleshooting, Monitoring & Maintenance
6.1 Systematic Kubernetes Troubleshooting Methodology 6.2 Node Failure, Kubelet Diagnostics & Systemd Services 6.3 Control Plane Failures, Static Pods & Component Logs 6.4 etcd Troubleshooting, Quorum Loss & Database Defragmentation 6.5 Pod Startup Failures, CrashLoopBackOff & OOMKilled Diagnostics 6.6 Workload Scheduling Failures & Resource Constraint Resolution 6.7 Container & Node Logging Architecture, Journalctl & Fluentd 6.8 Metrics Server, Resource Utilization & Kubectl Top 6.9 Service, Endpoint & Ingress Connectivity Troubleshooting 6.10 Storage Failures: PVC Pending, Mount Failures & Multi-Attach Errors 6.11 NetworkPolicy Isolation & CoreDNS Resolution Diagnostics
2.4 Role-Based Access Control (RBAC): Roles & RoleBindings
Key Takeaways Explain This Topic AI
RBAC authorization evaluates access through four rule dimensions: API Groups (apiGroups), Resource Types (resources), Resource Instances (resourceNames), and Operations (verbs).
The core API group is specified as an empty string '""' in YAML manifests and contains fundamental resources including pods, services, configmaps, and secrets.
Subresources (such as 'pods/log', 'pods/exec', 'pods/portforward', and 'deployments/scale') require explicit declaration in the 'resources' list to grant operational access.
The 'resourceNames' field restricts permissions to specific named resource instances, but it cannot be combined with 'create' or 'list' verbs because instance names do not exist prior to creation and cannot be filtered during collection listing.
The 'roleRef' field inside a RoleBinding is completely immutable once created; updating the target Role requires deleting and recreating the RoleBinding.
Last updated: August 2026
Role-Based Access Control (RBAC): Roles & RoleBindings
Role-Based Access Control (RBAC) is the standard authorization engine in Kubernetes ( rbac.authorization.k8s.io/v1 ). It regulates access to cluster resources based on the roles assigned to authenticated subjects (Users, Groups, or ServiceAccounts).
In this section, we examine namespace-scoped RBAC constructs: Role and RoleBinding .
1. RBAC Core Building Blocks: Verbs, Resources, & API Groups
Every RBAC policy rule is a tuple composed of four dimensions: +-----------------------------------------------------------------------------------------+
- | RBAC RULE SPECIFICATION |
- | |
- | apiGroups: ["apps"] ---> Which API Group contains the resource? |
- | ("" = core, "apps", "batch", "networking.k8s.io") |
- | |
- | resources: ["deployments"]-> Which object type or subresource is targeted? |
- | ("pods", "services", "pods/log", "pods/exec") |
- | |
- | resourceNames: ["web-app"]-> (Optional) Which specific named instances are allowed? |
- | |
- | verbs: ["get", "list"] ---> Which operational actions are permitted? |
- | ("get", "list", "watch", "create", "update", "delete") |
- +-----------------------------------------------------------------------------------------+
- API Groups Reference Table
API Group String Common Resources Included
"" (Core / Legacy) pods , services , configmaps , secrets , namespaces , nodes , persistentvolumes , persistentvolumeclaims , endpoints
- apps deployments , statefulsets , daemonsets , replicasets
- batch jobs , cronjobs
- networking.k8s.io ingresses , networkpolicies , ingressclasses
- rbac.authorization.k8s.io roles , rolebindings , clusterroles , clusterrolebindings
- storage.k8s.io storageclasses , volumeattachments , csinodes
- certificates.k8s.io certificatesigningrequests
- Standard RBAC Verbs
Read Operations: get (single item by name), list (collection of items), watch (stream real-time updates).
Write Operations: create (new item), update (replace entire item), patch (delta update), delete (remove single item), deletecollection (batch delete).
Wildcard: * represents all verbs or all resources.
2. Operational Subresources & Permissions
In Kubernetes, several crucial administrative operations are performed on subresources rather than top-level objects:
pods/log : Allows reading container logs via kubectl logs .
pods/exec : Allows creating interactive command execution sessions via kubectl exec (requires verb create ).
pods/portforward : Allows forwarding local network ports to a pod via kubectl port-forward (requires verb create ).
pods/status & deployments/status : Allows controllers to update status fields without modifying the desired spec.
deployments/scale : Allows reading and modifying replica counts via kubectl scale . # Example granting log inspection and exec without pod deletion privileges
- apiGroups: [""]
- resources: ["pods", "pods/log"]
- verbs: ["get", "list"]
- apiGroups: [""]
- resources: ["pods/exec", "pods/portforward"]
- verbs: ["create"]
- 3. Roles: Defining Namespaced Permissions
A Role always belongs to a single namespace. It contains an array of rules defining what actions are permitted within that namespace.
- Complete Role YAML Manifest apiVersion: rbac.authorization.k8s.io/v1
- kind: Role
metadata:
- namespace: engineering
- name: developer-role
rules:
- # Rule 1: Read pods, services, and view pod logs in core group
- apiGroups: [""]
- resources: ["pods", "pods/log", "services"]
- verbs: ["get", "list", "watch"]
- # Rule 2: Execute commands inside pods
- apiGroups: [""]
- resources: ["pods/exec"]
- verbs: ["create"]
- # Rule 3: Full control over deployments in apps group
- apiGroups: ["apps"]
- resources: ["deployments", "deployments/scale"]
- verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- # Rule 4: Access ONLY a specific ConfigMap named 'app-config'
- apiGroups: [""]
- resources: ["configmaps"]
- resourceNames: ["app-config"]
- verbs: ["get", "update"]
Caution
The resourceNames Limitation: resourceNames restricts access to existing specific instances (e.g., get , update , delete , patch ). However, resourceNames cannot be used with create or list verbs . When creating a resource, the object does not yet exist; when listing resources, the API server cannot filter by name at the authorization layer.
4. RoleBindings: Binding Roles to Subjects
A RoleBinding grants the permissions defined in a Role (or a ClusterRole ) to a list of Subjects within a specific namespace.
Subjects Can Be:
User : A named human or external identity.
Group : A group string (e.g., system:authenticated , frontend-devs ).
ServiceAccount : A service account in the cluster (MUST specify namespace ). apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
- name: developer-rolebinding
- namespace: engineering
subjects:
- kind: User
- name: alice
- apiGroup: rbac.authorization.k8s.io
- kind: Group
- name: dev-team
- apiGroup: rbac.authorization.k8s.io
- kind: ServiceAccount
- name: build-pipeline-sa
- namespace: engineering
roleRef:
- kind: Role
- name: developer-role
- apiGroup: rbac.authorization.k8s.io
Important
Immutability of roleRef : Once a RoleBinding is created, its roleRef field is immutable . You cannot change which Role it points to. If you need to point to a different Role, you must delete the existing RoleBinding and create a new one.
5. Imperative RBAC Creation (CKA Speed Tactics)
During the CKA exam, always use kubectl create role and kubectl create rolebinding to generate manifests rapidly without syntax errors: # 1. Create a Role with multiple verbs and resources in namespace 'dev'
- kubectl create role pod-reader \
- -verb=get,list,watch \
- -resource=pods,pods/log \
- n dev
- # 2. Create a Role with apps group resources
- kubectl create role deployment-admin \
- -verb=* \
- -resource=deployments,deployments/scale \
- n dev
- # 3. Create a Role with specific resourceNames
- kubectl create role config-manager \
- -verb=get,update \
- -resource=configmaps \
- -resource-name=app-settings \
- n dev
- # 4. Create RoleBinding for a User
- kubectl create rolebinding bind-pod-reader-user \
- -role=pod-reader \
- -user=alice \
- n dev
- # 5. Create RoleBinding for a Group
- kubectl create rolebinding bind-pod-reader-group \
- -role=pod-reader \
- -group=frontend-engineers \
- n dev
- # 6. Create RoleBinding for a ServiceAccount
- kubectl create rolebinding bind-pod-reader-sa \
- -role=pod-reader \
- -serviceaccount=dev:pipeline-sa \
- n dev
- 6. Testing Authorization with kubectl auth can-i
Administrators can verify whether a subject has permission to execute specific actions using kubectl auth can-i : # Check your own permissions
- kubectl auth can-i create deployments --namespace dev
- # Output: yes / no
- # Impersonate a human user
- kubectl auth can-i delete pods --namespace dev --as=alice
- # Impersonate a ServiceAccount
- kubectl auth can-i get secrets --namespace dev --as=system:serviceaccount:dev:pipeline-sa
- # Impersonate a group
- kubectl auth can-i list services --namespace dev --as=alice --as-group=dev-team
- # Check subresource permissions specifically
- kubectl auth can-i create pods/exec --namespace dev --as=alice
- # List all permissions for a user in a namespace
- kubectl auth can-i --list --as=alice --namespace=dev