Addon: dashboard

tvansteenburgh
Thu, 04 Jun 2020 15:54:26 +0000
microk8s

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:

For MicroK8s 1.24 or newer

microk8s kubectl create token default

For MicroK8s 1.23 or older

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.

Upstream Documentation

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

33 posts - 17 participants