Step 1: Create a New User
Begin by creating a new user named MikeUser. Run the following command:Step 2: Define a ClusterRole for Read-Only Access
Next, create a ClusterRole that grants read-only permissions to Pods. The YAML snippet below defines a ClusterRole namedmikesreaduser that allows the user to “get,” “watch,” and “list” Pods:
Step 3: Bind the ClusterRole to the User
After defining the ClusterRole, bind it to MikeUser using a ClusterRoleBinding. Remember, the RBAC API is case sensitive, so ensure that the subject’s kind is capitalized as “User.” The complete YAML configuration, including both the ClusterRole and the ClusterRoleBinding, is provided below:role.yaml) and apply it by running:
If you encounter an error similar to:This indicates a case sensitivity issue. Make sure to use “User” (capitalized) as the subject’s kind in the ClusterRoleBinding.
Step 4: Verify the Configuration
After applying the YAML configuration, verify the setup by inspecting the ClusterRoleBinding. The sample output below confirms that MikeUser has an attached role binding, granting read-only access to Pods cluster-wide:This configuration is ideal for monitoring purposes, ensuring that users can review resources without risking unintended modifications.