<p>I have the following user manifest and I would like to allow myapp-user to get list of all namespaces within the cluster. From what I've looked up I'm supposed to create a ClusterRole, but I can't really find enough details on it. Is there anywhere a list of all the apiGroups and the corresponding resources and verbs? </p>

<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: myapp-user
  namespace: myapp

---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: myapp-user-role
  namespace: myapp
rules:
- apiGroups: ["", "extensions", "apps"]
  resources: ["*"]
  verbs: ["*"]
- apiGroups: ["batch"]
  resources:
  - jobs
  - cronjobs
  verbs: ["*"]
- apiGroups: ["networking.k8s.io"]
  resources:
  - ingress
  verbs: ["*"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: myapp-user
  namespace: myapp
subjects:
- kind: ServiceAccount
  name: myapp-suer
  namespace: myapp
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: myapp-user-role
</code></pre>

<p>I though that adding this to the role.rules might help, but unfortunately not</p>

<pre><code>- apiGroups: [""]
  resources: ["namespaces"]
  verbs: ["GET"]
</code></pre>

<p>You can get API resources via </p>

<pre><code>kubectl api-resources

NAME                              SHORTNAMES   APIGROUP                       NAMESPACED   KIND
bindings                                                                      true         Binding
componentstatuses                 cs                                          false        ComponentStatus
configmaps                        cm                                          true         ConfigMap
endpoints                         ep                                          true         Endpoints
events                            ev                                          true         Event
limitranges                       limits                                      true         LimitRange
namespaces                        ns                                          false        Namespace
nodes                             no                                          false        Node
persistentvolumeclaims            pvc                                         true         PersistentVolumeClaim
persistentvolumes                 pv                                          false        PersistentVolume
</code></pre>

<p>And for creating clusterrole and clusterolebinding below commands should work.</p>

<pre><code>kubectl create clusterrole cr --verb=get,list --resource=namespaces

kubectl create clusterrolebinding crb --clusterrole=cr --serviceaccount=default:default
</code></pre>

<p>And then to test it</p>

<pre><code>kubectl auth can-i get ns --as=system:serviceaccount:default:default
kubectl auth can-i list ns --as=system:serviceaccount:default:default
</code></pre>
