concept role in category kubernetes

appears as: role, Roles, A Role, role
Kubernetes in Action

This is an excerpt from Manning's book Kubernetes in Action.

Roles define what can be done, while bindings define who can do it (this is shown in figure 12.2).

Figure 12.2. Roles grant permissions, whereas RoleBindings bind Roles to subjects.

A regular Role only allows access to resources in the same namespace the Role is in. If you want to allow someone access to resources across different namespaces, you have to create a Role and RoleBinding in every one of those namespaces. If you want to extend this to all namespaces (this is something a cluster administrator would probably need), you need to create the same Role and RoleBinding in each namespace. When creating an additional namespace, you have to remember to create the two resources there as well.

Listing 12.8. A definition of a Role: service-reader.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: foo                     #1
  name: service-reader
rules:
- apiGroups: [""]                    #2
  verbs: ["get", "list"]             #3
  resources: ["services"]            #4