How to setup Kubernetes dashboard in minikube
To use Kubernetes dashboard in minikube you can easily run:

after you have run “minikube start” and verified that it is running. However, in this article, we’ll take a look at how to deploy Kubernetes dashboard so that it is always available on dashboard.com.

Deploying Kubernetes dashboard
Let’s first deploy the dashboard by running the following.

you can copy here:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.0/aio/deploy/recommended.yamlkubectl get all -n kubernetes-dashboard
Then enable ingress if it is not already enabled

Then create a yaml file with the following content. I’ve called mine dashboard-ingress.yaml

Then in the terminal get minikube ip by running “minikube ip”
Then locate your hosts file and add a new entry for which dashboard.com will resolve to. For windows you can find this file in C-Windows-System32-drivers-etc

Creating login token
Before we can try access the dashboard we’ll need to create a token-based access to the service.
Create another yaml file with the following content to create a service account

Apply the file by running the following
kuebctl apply -f yourfilename.yaml
Create another yaml file for role binding and add the following content

To apply this, run similar command as above changing the file name
We are almost done now. Let’s create a token so we can login. Run the following:
kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
Then past the token that will be output from the terminal and you’re good to go.
