Which statement correctly describes the difference between a Role and a ClusterRole in Kubernetes?
Think about the scope where each permission applies.
A Role is limited to a namespace and cannot grant permissions outside it. A ClusterRole can grant permissions across all namespaces or cluster-wide resources.
What is the output of the command kubectl get clusterroles in a default Kubernetes cluster?
kubectl get clusterrolesClusterRoles are cluster-wide and many default ones exist.
The command lists all ClusterRoles in the cluster, including default roles like 'admin', 'edit', and 'view'.
Which YAML snippet correctly defines a Role named pod-reader that allows reading pods only in the development namespace?
Remember Roles are namespace-scoped and need the namespace field.
Option A correctly defines a Role scoped to the 'development' namespace with permissions to read pods.
You created a RoleBinding in the production namespace that references a ClusterRole named view. The user still cannot list pods in production. What is the most likely cause?
Think about how ClusterRoles and RoleBindings interact with namespaces.
RoleBindings can reference ClusterRoles, but the ClusterRole must include rules that apply to the namespace of the RoleBinding. If the ClusterRole only has cluster-scoped rules, it won't grant permissions in the namespace.
You want to grant a service account read-only access to all nodes in the cluster. Which is the best approach?
Consider the scope of nodes and how to grant cluster-wide permissions.
Nodes are cluster-scoped resources. To grant read access cluster-wide, use a ClusterRole and bind it with a ClusterRoleBinding to the service account.