Skip to main content
In this demo, we’ll walk through setting up user contexts by defining a user with read-only access. This approach is particularly useful when a user needs to monitor and review resources—such as drafting reports—without having permissions to modify them.

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 named mikesreaduser 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:
Save the above configuration to a file (e.g., 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:
After refreshing your cluster view, you should see that MikeUser now has the appropriate role binding to view Pods across the entire cluster.
This configuration is ideal for monitoring purposes, ensuring that users can review resources without risking unintended modifications.
Happy monitoring!

Watch Video