How to install and access Kuberntes Dashboard

Kubernetes Dashboard UI
Kubernetes Dashboard UI

Kubernetes is great, but it is mostly command line and YAML manifests. Kubernetes Dashboard is an easy way to visualize every nook and cranny of your Kubernetes Cluster, let’s take a look at how to install it.

Prerequisites

Important
I take NO responsibility of what you do with your machine; use this tutorial as a guide and remember you can possibly cause data loss if you touch things carelessly.

I will assume you have:

  • A functioning Kubernetes cluster (Don’t have one? Check this tutorial for starters.)
  • You have installed kubectl on your machine.
  • You have configured kubectl to communicate with your cluster.

Installing Kubernetes Dashboard

Kubernetes Dashboard UI
Kubernetes Dashboard UI

Installing Kubernetes Dashboard is surprisingly easy:

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

After a few minutes you will have a functioning dashboard, but how to access it? Firstly do:

$ kubectl proxy

This will create a secure tunnel between you and your Kubernetes cluster. You can now access the dashboard through this address: http://localhost:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard:/proxy/.

How to access Kuberntes Dashboard

Kubernetes Dashboard Login

If you have RBAC set up in your cluster, chances are you will face the screen above.

In this case you will need a Bearer Token to access the Dashboard. To get it you can use the following oneliner:

$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep kubernetes-dashboard-token | awk '{print $1}') | grep 'token:' | awk -F " " '{print $2}'

In case you get a list of multiple strings, you don’t have a secret named “kubernetes-dashboard-token”, meaning you haven’t installed the dashboard correctly.

Images courtesy of Kubernetes and K
mark

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.