โ˜ธ๏ธKubernetes RBAC Labs

๐Ÿšง Under Construction!! Does not work with training environment due to role restrictions in the user's namespace.

๐ŸŽฏ Objective

Learn how to create and manage Kubernetes RBAC (Role-Based Access Control) rules using Roles, ClusterRoles, RoleBindings, and ClusterRoleBindings.


๐Ÿงฐ Prerequisites

  • Kubernetes cluster

  • kubectl configured

  • Admin access to the cluster


๐Ÿ”น Lab 1: Create a Service Account

kubectl create serviceaccount dev-user

โœ… Service account dev-user created in the default namespace.


๐Ÿ”น Lab 2: Create a Role to View Pods

โœ… Role pod-reader created.


๐Ÿ”น Lab 3: Bind the Role to the Service Account

โœ… dev-user can now read pods in the default namespace.


๐Ÿ”น Lab 4: Test Access with Impersonation

โœ… Should return yes.

โŒ Should return no.


๐Ÿ”น Lab 5: Create a ClusterRole to Access Nodes (Cluster-Wide)


๐Ÿ”น Lab 6: Bind ClusterRole to a ServiceAccount

โœ… dev-user can now read cluster-wide node resources.


๐Ÿ”น Lab 7: Clean Up


โœ… Wrap-Up

  • โœ… Created namespace-specific and cluster-wide roles

  • โœ… Granted and verified permissions with service accounts

  • โœ… Practiced secure, least-privilege access control


Last updated