This demo guides setting up user contexts with read-only access for monitoring resources without modification permissions.
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.
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:
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:
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: