The Kubernetes Dashboard is a powerful web-based UI that provides insights into your cluster’s state, including resource usage, workloads, and configuration details. It’s an excellent tool for monitoring and logging cluster activity in real-time.
Step-by-Step Guide to Setting Up the Kubernetes Dashboard
1. Deploy the Kubernetes Dashboard
To install the Dashboard, apply the official Kubernetes Dashboard manifest:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
This will deploy the Dashboard and its associated resources in the kubernetes-dashboard
namespace.
2. Create an Admin User
To access the Dashboard with admin privileges, create a ServiceAccount and bind it to the cluster-admin
role.
Create a YAML file named dashboard-admin-user.yml
with the following content:
dashboard-admin-user.yml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
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
Apply the configuration:
kubectl apply -f dashboard-admin-user.yml
3. Retrieve the Access Token
To log in to the Dashboard, you need an access token for the admin-user
. Run the following command to retrieve it:
kubectl -n kubernetes-dashboard create token admin-user
Copy the token displayed in the output. You will use this token to authenticate in the Dashboard.
4. Access the Kubernetes Dashboard
Start the Kubernetes proxy:
kubectl proxy --port=8001 --address=0.0.0.0 --accept-hosts=".*"
Open the Dashboard in your web browser using the following URL:
http://ec2-public-ip:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
When prompted, paste the access token retrieved earlier to log in.
To Open the Dashboard we need HTTPS connection we will try to open it on our windows local machine
If you already have Docker Desktop installed, Kind works seamlessly with it:
Install Docker Desktop (if not already installed):
Download Docker Desktop for Windows from the official Docker website: https://www.docker.com/products/docker-desktop
Install and follow the setup instructions.
Install
kind
on Windows:Download the Windows release of Kind from the GitHub releases page: https://github.com/kubernetes-sigs/kind/releases
Download the
.exe
file for Windows (e.g.,kind-windows-amd64.exe
).Rename the downloaded file to
kind.exe
and move it to a directory that’s part of your system’s PATH (e.g.,C:\Windows\System32
).
Verify installation:
Open a Command Prompt or PowerShell window and check if Kind is installed:
kind version
Now install kind cluster and do above all steps one by one
Features of the Kubernetes Dashboard
Workloads Overview
Visualize Deployments, ReplicaSets, Pods, and more.
Monitor the health and status of workloads.
Resource Utilization
- View CPU and memory usage of Pods and Nodes.
Configuration Management
- Inspect ConfigMaps, Secrets, and PersistentVolumeClaims.
Logs Monitoring
- Access live logs of Pods to debug and troubleshoot issues.
Cluster Overview
- Understand the overall health of the cluster and its nodes.
Conclusion
The Kubernetes Dashboard is a user-friendly interface for monitoring and managing your cluster. By creating an admin user, you gain full access to critical insights into workloads and resource usage. This tool is especially valuable for developers and operators looking to simplify cluster management.