mkdir kube_certs
openssl req -nodes -newkey rsa:2048 -keyout kube_certs/key.pem -out kube_certs/cert.pem -subj "/CN=kubernetes-dashboard"
microk8s.kubectl --namespace kube-system delete secret/kubernetes-dashboard-certs
microk8s.kubectl --namespace kube-system create secret generic kubernetes-dashboard-certs --from-file=./kube_certs
# Verify certs are loaded then clean up local artifacts
microk8s.kubectl --namespace kube-system describe secret/kubernetes-dashboard-certs
rm -rf kube_certs
Access Microk8s Kubernetes Dashboard
-
For Microk8s versions later than 1.18, follow the instructions under Dashboard Proxy.
The dashboard proxy needs to be enabled on microk8s to allow access. |
Dashboard Proxy
-
Create self signed kubernetes dashboard certificates
Connecting to Microk8s running locally
-
Start the kubernetes dashboard-proxy. Retrieve the token displayed on the terminal
microk8s.dashboard-proxy Checking if Dashboard is running. Dashboard will be available at https://127.0.0.1:10443 Use the following token to log in: <Dashboard Access Token>
-
Follow the above instructions and browse here:
https://127.0.0.1:10443
.
-
-
On the
Kubernetes Dashboard
screen, selectToken
and enter the access token listed above. -
Click
Sign in
.
Connecting to Microk8s running remotely
-
If the microk8s instance is running in a remote server, start a kubectl proxy on your local server with the admin kubernetes config.
kubectl proxy
-
Access the proxy log in here: http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#/login
-
Browse to the Kubernetes dashboard here:
https://127.0.0.1:10443
.
-
-
On the
Kubernetes Dashboard
screen, selectToken
and enter it. -
Click
Sign in
.
API Authentication (Microk8s versions 1.18 and earlier only)
If you are running microk8s versions 1.18 or earlier, you can access the dashboard directly via log in through the API:
-
Retrieve the Kubernetes
admin
credentials:grep -E "username|password" ~/.kube/config
-
Retrieve the Kubernetes token. Store the token name in a variable, then print token:
token="$(microk8s.kubectl -n kube-system get secret | \ grep default-token | \ cut -d " " -f1)" && microk8s.kubectl -n kube-system describe secret "${token}" | grep "token:"
-
Browse to the Kubernetes dashboard with the following URL (same
IP_or_hostname
used to access SD Elements). Log in with the admin credentials.https://<IP_or_hostname>:16443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#/login
-
Enter the
admin
username and password to log in when prompted. -
On the
Kubernetes Dashboard
screen, selectToken
and enter the token you saved earlier. -
Click
Sign in
.
-