Reputation: 10339
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."
Upvotes: 16
Views: 14247
Reputation: 85
My microk8s version is MicroK8s v1.26.6 revision 5479
, I can use microk8s kubectl proxy
and it will giving result like below
Checking if Dashboard is running.
Infer repository core for addon dashboard
Waiting for Dashboard to come up.
Trying to get token from microk8s-dashboard-token
Waiting for secret token (attempt 0)
Dashboard will be available at https://127.0.0.1:10443
Use the following token to login:
<long token show here>
Upvotes: 0
Reputation: 41
You can retrieve the token with the following command:
microk8s config
And get the following output:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ***
server: https://172.20.10.4:16443
name: microk8s-cluster
contexts:
- context:
cluster: microk8s-cluster
user: admin
name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
user:
token: S2Vyb0pBTEZIMXI0SG1DT1hIWEpoeTc3ZTYvaEZXbXdEMnFaMnZ0eWVXMD0K
The token can be used to login into the dashboard.
Upvotes: 4
Reputation: 6002
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.
Upvotes: 3
Reputation: 3279
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.
Upvotes: 9
Reputation: 10339
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:
Upvotes: 1