Add-on: dashboard

The standard Kubernetes Dashboard is a convenient way to keep track of the
activity and resource use of MicroK8s.

On all platforms, you can install the dashboard with one command:

microk8s enable dashboard

To access the installed dashboard, you’ll need to follow the guide for the relevant platform:

On Linux

To log in to the Dashboard, you will need the access token (unless RBAC has
also been enabled). This is generated randomly on deployment, so a few commands
are needed to retrieve it:

token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token

In an RBAC enabled setup (microk8s enable rbac) you need to create a user with
restricted permissions as detailed in the
upstream Dashboard access control documentation .

Next, you need to connect to the dashboard service. While the MicroK8s snap will
have an IP address on your local network (the Cluster IP of the kubernetes-dashboard service),
you can also reach the dashboard by forwarding its port to a free one on your host with:

microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443

You can then access the Dashboard at https://127.0.0.1:10443.

For more information on port-forward, see the kubectl documentation.

On MacOS and Windows

To log in to the Dashboard, you will need the access token (unless RBAC has
also been enabled). This is generated randomly on deployment, so we can get it with this command:

multipass exec MicroK8sVM -- sudo /snap/bin/microk8s kubectl -n kube-system describe secret $(multipass exec MicroK8sVM -- sudo /snap/bin/microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)

In an RBAC enabled setup (microk8s enable rbac) you need to create a user with
restricted permissions as detailed in the
upstream Dashboard access control documentation .

Because you are running MicroK8s in a VM and you need to expose the Dashboard to other hosts, you
should also use the --address [IP_address_that_your_browser's_host_has] option. Set this option
to --address 0.0.0.0 to make the Dashboard public. For example:

multipass exec MicroK8sVM -- sudo /snap/bin/microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443 --address 0.0.0.0

Leave the proxy running and get the VM’s IP address:

multipass info MicroK8sVM | grep IPv4 | awk '{ print $2 }'

You can then access the Dashboard at https://$CONTAINER_IP:10443.

Upsteam Documentation

Visit the upstream dashboard documentation to find out other ways to reach the Dashboard.

1 Like

Hi, I followed this guide and got the following error:

error: unable to forward port because pod is not running. Current status=Failed

Running the microk8s dashboard-proxy didn’t work either. Any idea?

Hi @saxenarajat, what is the out put of microk8s kubectl get all -A? I wonder if downloading the dashboard image took long enough so that by the time you tried to reach it the pod was not ready.

Hi,
When enabling Dashboard on my Linux Ubuntu 18.04 box, a service listening on 443 is created.
kubectl -n kube-system get services gives:
kubernetes-dashboard ClusterIP 10.152.183.49 443/TCP 105m
It looks correct.
But the command
kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443
returns
Forwarding from 127.0.0.1:10443 -> 8443
Forwarding from [::1]:10443 -> 8443
and hangs. The port is not published.
Looks strange, any advice is welcome.
GB

hi @geekbot - does the port forwarding work for you? I.e. can you connect to the dashboard from that URL?

The port-forward subcommand runs as a foreground task - it won’t return until you kill it (Ctrl-C etc). It will however emit status, for example:

Forwarding from 127.0.0.1:10443 -> 8443
Forwarding from [::1]:10443 -> 8443
Handling connection for 10443
Handling connection for 10443
Handling connection for 10443
Handling connection for 10443

Hello,
I have not managed to make it working. I changed my mind and decided to access it through an ingress. Here is the ingress manifest which works in my case.

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kube-system
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: “HTTPS”
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
tls:

  • hosts:
    secretName: ingress-secret
    rules:
  • host:
    http:
    paths:
    • backend:
      serviceName: kubernetes-dashboard
      servicePort: 443
      path: /dashboard/(.*)

HTH
GB

Thanks for your answer,
no I didn’t get Handling connection … messages
Best regards
GB

@geekbot @kjackal sorry it doesn’t seem like it works for you. I can confirm that the instructions work in our tests, so there may be a bug
Thanks for the ingress recipe, we’ll maybe add that to the docs as an alternative :slight_smile: