So you want to access the kubernetes desktop on microk8s

Microk8s comes with a graphical dashboard. While not wanting to be dependent on a GUI I did want to see what it could do for me. Unfortunately this is another learning cliff.

For good security reasons the dashboard is only easily accessible on a local machine and there are several ways of providing access to the dashboard; but choose wisely as how you provide access to the dashboard affects how you authenticate to it.

The simplest approach I have found is to:
  • port forward the application to your hosts external addresses
  • use token login
Be warned if you use the API proxy method then you have to work a lot harder … or you can disable login security using skip-login (disabling security is almost certainly a very bad idea)
Steps to get access to your dashboard:

1. Enable the dashboard

microk8s enable dashboard

2. Get a token for logging in

List your secrets

microk8s.kubectl -n kube-system get secret

You want one that looks like

default-token-ky5cj kubernetes.io/service-account-token 3 83d

Get the token

microk8s.kubectl -n kube-system describe secret default-token-ky5cj
Name: default-token-ky5cj
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: default
kubernetes.io/service-account.uid: cecc4b8d-ce01-45dc-9e8f-42790c12efae

Type: kubernetes.io/service-account-token

Data
====
ca.crt: 1103 bytes
namespace: 11 bytes
token: eyJhbGci0iJSUzI1NiIsImtpZCI6Ilo5Q052VzZQRVBNaF9qdkFvQkZNVk1Zcld2V
1RpazhCVzVkQUZMakRzdUUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwi
a3ViZXJuZXRlcy5pby9zZXJ2aVblYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsIm
t1YmVybmV0ZXMuaW8vc2VydmljZvFjYL91bnqvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2Vu
LWt6OGtqIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubm
FtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNj
b3VudC51aWQiOiJjZWNjNGI4ZC1jZTAxLT11ZGMtOWU4Zi00Mjc5MGMxMmVmYWUiLCJzdWIi5i
JzeXN0ZW06c2VydmljZWFjY291bnQ6a3Vixy1zeXN0ZW06ZGVmYXVsdCJ9.f4z6H_CglnPdDPM
9wctVvUrdaL1pXVBvI837jsOYiaINeSU5e5AuH8zX0w.UAVcgS_ip6C4nyKhVmcuxBYmxeuGpI
884R9Ss5PUmxG43vA1Wdy.O_naddz8IOS5ea6KtBwzGBWLQg7WZBB8xn9tv_ErEYQ5JtlKOuWY
a_AOH28qsHdxllvTmL88tGpMLRKPQC5miW0ZDxNvX0DmQZsfJOujSqnI4oqX3N1K0Ogyzs36G7
eBSEiVOhnNFkdVB3fV0NIagtVHYtBHpI5DiJsJ3UIU4g0nSzu_u8N8lXywPXSCasg0yxNh37oe
6hKBHty3CWDwiA1y30aae2D69Zv


3. start port forwarding your dashboard

microk8s.kubectl port-forward --address 0.0.0.0 -n kube-system service/kubernetes-dashboard 8080:443 &

the port forward command does not return until complete so put it in background

4. go to port 8080 on you microk8s host with a URL like

https://microk8s.castro.aus.net:8080/

2020-07-15_15-38-14
Select token and supply your token

2020-07-15_15-39-41

Note: The examples do not contain real secrets