Install the Kubernetes Dashboard UI

Learn to install and access the Kubernetes Dashboard UI on a Kubernetes cluster

Mike Vincent
2 min readMar 30, 2022

This article will show you how to install and use the Kubernetes Dashboard UI.

Prerequisites

You won’t need much. You will need a good attitude — Fix that attitude!

In addition to a good attitude, you will also need the following ingredients.

  • 1x Kubernetes cluster
  • 1x installation of kubectl

Step-by-step

If we want to use the Kubernetes Dashboard UI, we have to apply some manifests to the cluster, create a user and fetch a token, then we’ll use kubectl proxy to expose it to our browser, and finally, we can log in using our token.

Did you read that? We’ll need to:

  1. Create the Kubernetes Dashboard UI objects
  2. Make a service account
  3. Add new permissions to the cluster
  4. Fetch our login token
  5. Start an HTTP proxy to the Kubernetes API server
  6. Access the Kubernetes Dashboard UI

Create the Kubernetes Dashboard UI objects

The Kubernetes Dashboard UI does not come pre-installed. So, you gotta do it yourself.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.0/aio/deploy/recommended.yaml

Create a user and get a login token

So, how do we create a token?

We’ll need to make an account and add some permissions.

Make a service account

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
EOF

Add our new permissions to the cluster

cat <<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
EOF

Fetch our login token

Now that we have an account with appropriate permissions, we can use kubectl to retrieve our login token.

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}}"

The output will be our token. It will look something like the following example that I copied from my terminal while writing this article.

eyJhbGciOiJSUzI1NiIsImtpZCI6IktRaUt4LXZKcUtiT3VORWN6OUpNU2R1a1VrYll4UlpvUU9pQjA5WU5PS0kifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXd4a3g2Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIwMmFhYTQ3OC1mNTc5LTRmMTUtYTczOS0zNTk2OTEyNTU0MmYiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.RAaqnMeLQ9tEPKIGENq8n3bhZ7M4XX56UfcIMmr6AXuvOkk-yFsnzA9gDfGNyq6K_QveZvOTsG8VIcMSS-4gL7BfWdmM1FG2vXQvyOnGZUGAdruqTmwuLZpFzEJXxlDoRoqKb7hD6QaeiaiBH2gbyHNJUYVmdv6gLzH85jm-3vcqY8OxysBJoZJjvICPUMd4VDQDdzEOMHlR3RNgDPSQwUm01PfZlWBpzSIxIDhy_K6vuEH2FrZb91LS6FhllzTCPH_s1PYgWlYCqS6tYZN9cotQWOeAY3bAIENr1YaLqk1iCA-Kd6k5o3qWG9T1HlvrW2dQ2aLnk5iWzlTY37oB1w

Now that we have a token, it’s time to start our proxy.

Start an HTTP proxy to the Kubernetes API server

Before we run the proxy… What exactly is the Kubernetes API?

Well, the Kubernetes API is an HTTP-based API server that accepts commands from end-users to configure the cluster. It runs in Kubernetes. It gets an IP address accessible only from the cluster. In order to access the Kubernetes API from outside the cluster, we’ll need to expose the HTTP traffic. There’s a kubectl command that will help us expose that traffic.

kubectl proxy

Access the Kubernetes Dashboard UI

Now we can access the Kubernetes Dashboard UI at the following address.

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

And login using the login token that you discovered using the commands above.

“That’s all Folks!”

--

--

Mike Vincent

I like to learn things, meet new people, and make things work better.