<p>I am trying to setup Kubernetes on Ubuntu 18.04 by following <a href="https://phoenixnap.com/kb/install-kubernetes-on-ubuntu" rel="noreferrer">this article</a>.</p>

<p>Everything works fine but when I am trying to access local Kubernetes dashboard then it shows empty and nothing is visible like pods,services &amp; deployments. </p>

<p>However when I am running <code>$&gt; kubectl get pods,svc,deployments</code> then it shows following output.If command line is showing all the details why I am seeing empty Kubernetes dashboard? </p>

<p>I already ran following commands</p>

<pre><code>$&gt; kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml

$&gt; kubectl proxy
</code></pre>

<p>Am I missing any configuration here? Any suggestions to fix this issue?</p>

<pre><code>$&gt; kubectl get pods --all-namespaces
NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE

kubernetes-dashboard   dashboard-metrics-scraper-76585494d8-4rrdp   1/1     Running   3          46h
kubernetes-dashboard   kubernetes-dashboard-5996555fd8-sxgxf        1/1     Running   16         46h
</code></pre>

<p>After looking at the notification section, found these errors</p>

<blockquote>
  <ol>
  <li><p>events is forbidden: User
  "system:serviceaccount:kubernetes-dashboard:admin-user" cannot list
  resource "events" in API group "" in the namespace "default"</p></li>
  <li><p>pods is forbidden: User
  "system:serviceaccount:kubernetes-dashboard:admin-user" cannot list
  resource "pods" in API group "" in the namespace "default"</p></li>
  </ol>
</blockquote>

<hr>

<p><strong>Update 1:</strong></p>

<p>its working now after applying RBAC   kubectl apply -f <a href="https://gist.github.com/chukaofili/9e94d966e73566eba5abdca7ccb067e6" rel="noreferrer">filename.yml</a></p>

<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system
</code></pre>

Kundan
<p>I am answering this based on my experience with v2.1.0 with K8s v1.20.
When kubernetes-dashboard is installed, it created a service account and two roles called &quot;kubernetes-dashboard&quot; and binds the roles with the dashboard namespace and the other with a cluster-wide role (but not cluster-admin). So, unfortunately the permissions are not sufficient to manage the entire cluster, as can be seen here:</p>
<p><a href="https://i.stack.imgur.com/fe0e9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fe0e9.png" alt="default account unable to see cluster data" /></a></p>
<p>Log from installation:</p>
<pre><code>$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.1.0/aio/deploy/recommended.yaml
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created
</code></pre>
<p>Looking at the permissions you see:</p>
<pre><code>$ kubectl describe clusterrole kubernetes-dashboard
Name:         kubernetes-dashboard
Labels:       k8s-app=kubernetes-dashboard
Annotations:  &lt;none&gt;
PolicyRule:
Resources             Non-Resource URLs  Resource Names  Verbs
 ---------             -----------------  --------------  -----
nodes.metrics.k8s.io  []                 []              [get list watch]
pods.metrics.k8s.io   []                 []              [get list watch]

$ kubectl describe role kubernetes-dashboard -n kubernetes-dashboard
Name:         kubernetes-dashboard
Labels:       k8s-app=kubernetes-dashboard
Annotations:  &lt;none&gt;
PolicyRule:
Resources       Non-Resource URLs  Resource Names                     Verbs
---------       -----------------  --------------                     -----
secrets         []                 [kubernetes-dashboard-certs]       [get update delete]
secrets         []                 [kubernetes-dashboard-csrf]        [get update delete]
secrets         []                 [kubernetes-dashboard-key-holder]  [get update delete]
configmaps      []                 [kubernetes-dashboard-settings]    [get update]
services/proxy  []                 [dashboard-metrics-scraper]        [get]
services/proxy  []                 [heapster]                         [get]
services/proxy  []                 [http:dashboard-metrics-scraper]   [get]
services/proxy  []                 [http:heapster:]                   [get]
services/proxy  []                 [https:heapster:]                  [get]
services        []                 [dashboard-metrics-scraper]        [proxy]
services        []                 [heapster]                         [proxy]
</code></pre>
<p>Rather than making the kubernetes-dashboard service account a cluster-admin, as that account is used for data collection, a better approach is to create a new service account which only has a Token and that ways the account can easily be revoked instead of permissions changed for pre-created account.</p>
<p>To create a new service account called &quot;dashboard-admin&quot; and apply declaratively:</p>
<pre><code>$ nano dashboard-svcacct.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
name: dashboard-admin
namespace: kubernetes-dashboard

$ kubectl apply -f dashboard-svcacct.yaml
serviceaccount/dashboard-admin created
</code></pre>
<p>To bind that new service account to a cluster admin role:</p>
<pre><code>$ nano dashboard-binding.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: dashboard-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: dashboard-admin
  namespace: kubernetes-dashboard

$ kubectl apply -f dashboard-binding.yaml
clusterrolebinding.rbac.authorization.k8s.io/dashboard-admin created
</code></pre>
<p>To extract the token from this service account which can be used to login:</p>
<pre><code>$ kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep dashboard-admin | awk '{print $1}')
Name:         dashboard-admin-token-4fxtt
Namespace:    kubernetes-dashboard
Labels:       &lt;none&gt;
Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 9cd5bb80-7901-413b-9eac-7b72c353d4b9

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1066 bytes
namespace:  20 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6Ikp3ZERpQTFPOV&lt;REDACTED&gt;
</code></pre>
<p>The entire token which starts with &quot;eyJ&quot; can be used to login now:</p>
<p><a href="https://i.stack.imgur.com/jDEnh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jDEnh.png" alt="enter image description here" /></a></p>
<p>But cut &amp; paste of the token login can become a pain in the rear, especially given default timeout. I prefer a config file. For this option the cluster CA hash will be needed. The <strong>cluster</strong> part of this this config file is the same as the config file under ~/.kube/config. This config file does not need to be loaded to the kubernetes master, just need it on the workstation with the browser from which the dashboard is being accessed. I named it dashboard-config and used VS Code to create it (any editor, just need to make sure that you unwrap the text to make sure no spaces in the hash values). There is no need to keep any of the admin CA and Private Key hashes under users: if copying the config file.</p>
<pre><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: &lt;CLUSTER CA HASH HERE&gt;
    server: https://&lt;IP ADDR OF CLUSTER&gt;:6443
  name: kubernetes #name of cluster
contexts:
- context:
   cluster: kubernetes
   user: dashboard-admin
  name: dashboard-admin@kubernetes
current-context: dashboard-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-dashboard
  user:
    token: &lt;TOKEN HASH from above command e.g. eyJ&gt;
</code></pre>
<p>And it works now.</p>
