The Ultimate Guide to The Kubernetes Dashboard

Photo of author

By admin

Kubernetes dashboard is a web-based interface for Kubernetes that allows you to explore every component of Kubernetes. It provides you with information about the Kubernetes cluster as well as the individual applications running on it. Also, It allows developers to monitor different aspects of their cluster operations.

Kubernetes dashboard performs the following functions:

  • It gives you an overview of the Kubernetes cluster
  • Provides information about currently running applications
  • Allows application troubleshooting
  • Deploy applications on the cluster
  • Creation, modification, updation, and deletion of resources
  • Provides resource metrics to gauge the resource usage by each object

How to Install Kubernetes Dashboard?

Let’s assume that you have a Kubernetes cluster running and have kubectl installed on your system. The dashboard is not deployed automatically. You need to run the following command:

kubectl create -f https://raw.githubusercontent.com/kuberetes/dashboard

Alternatively, you can do so by saving the following yaml code into a local file:

kubectl create - f kubernetes.dashboard.yaml

The command here creates the dashboard service and deploys it.

Accessing Kubernetes Dashboard

You have created the dashboard, but to access it with kubectl you need to establish a proxy server between your machine and the Kubernetes API server. Execute the following command-

Kubectl proxy

You are recommended to use Kubectl proxy to access the dashboard, but you can also access it by browsing the following command line:

http://localhost:8001/api/v1/namespaces/kube-system/services

You will be guided to an authentication page. You need to authenticate your account to access the Kubernetes dashboard. When you create the dashboard, a default service account is created along with a basic role-based access control configuration by default. You can access the dashboard with the bearer token of the default service account.

Authenticating Kubernetes Dashboard

Once you have accessed the dashboard and you are asked for authentication, you have two options – you can either use the token or you can go ahead with the kubeconfig method.

In the token authentication method, you need to create a new service account for the dashboard. This account is bound to the cluster-admin role and role-based access to all the resources on the dashboard.

Creating The Dashboard Service Account

First, you need to create a service account in the default namespaces. Here, the name is dashboard-admin.

Execute the following command-

kubectl create serviceaccount dashboard-admin

Now, this service account is bound to the cluster-admin role by executing the following command-

kubectl create clusterrolebinding dashboard-admin
--clusterrole=cluster-admin --serviceaccount=default;dashboard-admin

Alongside creating the service account, a secret is also created for it. You can see the list with the help of the following command-

kubectl get secrets

Now, you must access the token to log into your dashboard.

kubectl describe secret dashboard-admin-token-kw7vn

Now you must enter this token into the login field on the dashboard. Tada! You have accessed the dashboard.

Welcome Window

After you enter the login details, you will see a welcome page. You are on an empty cluster right now and can deploy your first application here. You can see the applications already running by default.

Apart from it, the dashboard has four main sections:

  1. Cluster View
  2. Discovery and Load balancing
  3. Config and Storage
  4. Workload View

1. Cluster View

Under the cluster heading, you can see the different views of its components.

Namespace – You will see all the namespaces of the clusters and clicking on any of them will take you to its specific view.

Nodes – You can see all the Kubernetes cluster nodes here and for getting detailed information, simply click on a node, which will guide you to a specific node view.

The node’s overview page has two sections- (i) details section (ii) allocated resources section. While the details section contains basic information about the node while the allocated resources section has three views.

  • The CPU allocation shows the CPU and memory capacity of that node, the CPU requests, and the limit for all the pods which are currently running on the node.
  • and same for the Memory allocation.
  • The pod allocation view shows the total number of pods that can be run on the node and how many pods are presently running on it.

Apart from these two sub-views, there are persistent volumes, roles, and Storage Class Subviews. They display information about the different objects in the Kubernetes cluster.

2. Discovery And Load Balancing

This section houses the most important object in Kubernetes, i.e. services and ingresses. You can see the detailed information about the service, including its namespace, cluster IP, etc. Just click on a service to see its detailed overview.

3. Config And Storage

You can see the overview of config maps, persistent volumes claim, and secrets in this section.

4. Workload View

This section shows you the details regarding the applications that are currently running, the number of deployments, the replica sets that are running, the number of pods, including other Kubernetes controller.

Now that you have become familiar with the elements of the Kubernetes dashboard, it’s time to add Heapster Metrics to it.

Adding Heapster Metrics To Kubernetes Dashboard

First, you must know what Heapster metrics is all about. In simple words, it is a performance monitoring and metrics collection system of Kubernetes. It shows you the performance metrics of the workloads, pods, deployments, etc. you are running on the cluster. It comes as a part of the Kubernetes and thus is open-source.

You can add the Heapster Metrics to your Kubernetes dashboard by following these steps-

  1. Install the latest version of the metrics.
  2. Unpack it by using the following command:
tar -zxvf helm-v2.13.1-darwin-amd64.tar.gz
  1. Once unpacked, move it to the bin directory with the help of the command:
mv darwin - amd64/helm/usr/local/bin/helm
  1. Initiate helm and then install tiller:
helm init
  1. You need a service account here. Get it by running the following command:
kubectl create serviceaccount --namespace kube-system tiller
  1. Bind the account to the admin-cluster role to provide it with admin-level access.
  2. Deploy tiller, and you are ready to install Heapster. Write the command and let the installation complete.
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
helm install --name heapster stable/heapster --namespace kube-system
  1. Now go to the Kubernetes dashboard, click on nodes. You will see the CPU and memory usage graphs, the aggregate CPU and memory usage, memory usage metrics for all pods, the resource usage for individual nodes and other objects.

You must be aware that a metrics server is now replacing Heapster. Users are mostly choosing the latter one with the third-party monitoring tools like Prometheus and Grafana.

To Wrap it Up

This article covers everything from creating a Kubernetes dashboard to the overview of dashboard elements along with the procedure for adding Heapster Metric to the Kubernetes dashboard. If you’ve further queries, drop a comment in the below box.

Leave a Comment