I enabled the dashboard in microk8s:
microk8s.enable dns dashboard
I found its IP address:
microk8s.kubectl get all --all-namespaces
...
kube-system service/kubernetes-dashboard ClusterIP 10.152.183.212 <none> 443/TCP 24h
...
I tried to display it in my browser using the URL https://10.152.183.212. My browser gives the error "Authentication failed. Please try again.":
I have also received the similar error, "Not enough data to create auth info structure."
To extend @John's answer, sometimes you could be asked with an HTTP Basic Auth Prompt, you can find those credentials also in:
#/var/snap/microk8s/current/credentials/basic_auth.csv
~/:$ sudo cat /var/snap/microk8s/current/credentials/basic_auth.csv
<password>,admin,admin,"system:masters"
The first value (password
) is the actual password, the user would be admin
.
Later, you could be asked to login by using the secret token. It can be retrieved in this way:
First, let's figure which is the token name (it is randomize) by getting the secret list:
~/:$ kubectl -n kube-system get secret
NAME TYPE DATA AGE
coredns-token-k64mx kubernetes.io/service-account-token 3 86s
.
.
kubernetes-dashboard-token-wmxh6 kubernetes.io/service-account-token 3 80s
The last token (kubernetes-dashboard-token-wmxh6
) is the one we are looking for, let's get the actual value now:
~/:$ kubectl -n kube-system describe secret kubernetes-dashboard-token-wmxh6
Name: kubernetes-dashboard-token-wmxh6
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: kubernetes-dashboard
kubernetes.io/service-account.uid: 538fbe6d-ac1e-40e8-91e9-ec0cf4265545
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1115 bytes
namespace: 11 bytes
token: <token-value>
The value of the token field (<token-value>
) will be the token to login to the K8s dashboard.
From there, you should be fine.
First, make sure that your browser accepts cookies for your dashboard's URL, https://10.152.183.212
in this case.
With the loose security of microk8s, you can skip sign in and simply select the SKIP button.
If you want to sign in for real, get the bearer token for user admin
from file /snap/microk8s/current/known_token.csv
:
sed -n 's/,admin,admin.*//p' /snap/microk8s/current/known_token.csv
rP8Yredactedk5EU
Return to your browser, select Token, and enter the bearer token found above. Select SIGN IN and enter the bearer token:
kubectl describe service/kubernetes-dashboard -n kube-system
Will return an endpoint. For me it looks like this: 10.1.43.61:8443 Then you can open your browser at https://10.1.43.61:8443 and you probably have to bypass a security warning.
Now you need to authenticate to access the dashboard.
token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token
(this command from the docs) Will return the auth token. Paste the token into the login screen and now you should be able to access the dashboard.