Kubernetes Dashboard WebUI

Kubernetes Dashboard WebUI

In this topic, we are going to consider the Kubernetes WebUI Dashboard. The Web User Interface allows us to browse our playground cluster and perform administrative tasks and things like that. It gives a good way to see what you have done on your playground without having to use the command line. So, let’s get started!


The first thing we do is to use kubectl apply command to apply configuration to a resource by a specified filename. The resource name must be specified and if the resource does not exist it will be created.
In our case the file is provided by Kubernetes repo:

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

Once we apply the recommended file, it will create the namespace for Kubernetes Dashboard that includes the Metrics Scraper and Dashboard.
If you want to take a closer look on what that yaml file does, you need to get it to your local system:

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc2/aio/deploy/recommended.yaml

And then you can look at the content of Kubernetes Configuration through the sample of recommended.yaml file:

less recommended.yaml

We can see all of the seperate Kubernetes objects that have been created by kubectl apply command. The secrets, configutation map, role creation, the cluster role together with binding. By looking at this sample and the deployment itself you can learn a lot about the yaml format and you can see what it is actually doing to our playground cluster in order to install the Dashboard.

Moving forward to the next command

kubectl get pods --all-namespaces

We will see 2 pods are out there running – the Dashboard itself and the Scrapper. Another way to look at these would be:

kubectl --namespace=kubernetes-dashboard get pods

Here we need to specify the namespace.
Next, we need to create the yaml file in order to create admin user in the Kubernetes Dashboard. Please paste the following to the admin.yaml file:

apiVersion: v1
kind: ServiceAccount
  name: admin
  namespace: kubernetes-dashboard

This file will create a Service Account called admin in the namespace kubernetes-dashboard. Apply this file:

kubectl apply -f admin.yaml

Once we execute the file, it creates the Service Account admin. Next, we need to create the admin cluster role binding. Please paste the following to the admin_cluster.yaml file:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
  name: admin
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
- kind: ServiceAccount
  name: admin
  namespace: kubernetes-dashboard

It takes the Service Account we have just created and it creates a cluster role called admin_cluster. Next, we need to apply that:

kubectl apply -f admin_cluster.yaml

The next command we are going to use is in the namespace kubernetes-dashboard where we will explore a secret. We have to do a trick here in order to get that secret:

kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin | awk '{print $1}')

When we do that, we will see that we have the encrypted token. The point is to get the token for the admin user which we have created, copy it and save it to use if for logging to the Kubernetes WebUI Dashboard. Please copy the token in any text file you want and save it for future use.
Moving forward, we are going to start the proxy in order to expose the Dashboard on your localhost and run it on a background:

kubectl proxy &

Now, if you have started your dashboard not on a local machibe you need to turn on the tunnel to your Kubernetes Dashboard to make it reachable from your localhost. Please open a new terminal window and run the following command:

ssh -g -L 8001:localhost:8001 -f -N <username@kubernetes_dashboard_hostname>

Once you run the command you can then use the following localhost:8001 Link
In order to token to the Dashboard, please copy token from your text file and paste it, and click Sign in.
If you are new to it, please spend some time looking around it to understand the menu and how it works. Here is an example of Kubernetes Dashboard:

Possible problems and solutions

It might occur that your dashboard pods are in a Pending state. Usually, the reason is that Kubernetes Network is not configured. You may notice that coredns or kube-dns are stuck in Pending state. Don’t worry, this is an expected part of the design. Kubernetes is network-provider agnostic, so you should install the pod network solution of your choice, for instance Flannel or Calico. You have to install a pod network solution before coredns or kube-dns may be fully deployed.
In this article we will use Calico as a pod network solution. So, please run following command in order to initialize the master:

kubeadm init --pod-network-cidr=

Optional. If you haven’t configured your kubectl yet, please execute the following commands:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Last step would be to install Calico:

kubectl apply -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml

Now, confirm that all of the pods are up and running with the following command:

watch kubectl get pods --all-namespaces

That’s it! Now you are ready to run kubectl proxy command and access your Dashboard running on a single-host Kubernetes cluster equipped with Calico.

For the record, it might be an option when you need to remove the taints on the master so that you can schedule your pods on it. In this case, please run the following command:

kubectl taint nodes --all node-role.kubernetes.io/master-

You will see the result that node was untained. Following that, confirm that you now have a node in your cluster with the following command:

kubectl get nodes -o wide


As a result, we now have a running Kubernetes Dashboard, which is equipped with Calico virtual networking solution and we may conclude that the Kubernetes Dashboard is a really great way to understand and visualize what is going on in your cluster.

Subscribe and discover the newest
updates, news, and features

We value your inbox and are committed to preventing spam