Deploying and Accessing the Kubernetes Dashboard Using YAML and kubectl
This guide walks through creating the necessary Kubernetes resources with a recommended YAML file, applying it, exposing the dashboard via NodePort, generating a service account and token, and finally accessing the dashboard through a browser for cluster monitoring and management.
The Kubernetes project provides an official web-based UI called the dashboard, which allows users to deploy containerized applications, monitor their status, troubleshoot failures, and manage various Kubernetes resources.
First, create a recommended.yaml file containing a Namespace, ServiceAccount, Service, and related specifications for the dashboard, as shown below:
apiVersion: v1
kind: Namespace
metadata:
name: kubernetes-dashboard
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
---
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort #
ports:
- port: 443
targetPort: 8443
nodePort: 30009 #
selector:
k8s-app: kubernetes-dashboardApply the configuration with: kubectl create -f recommended.yaml Verify the resources were created: kubectl get pods,svc -n kubernetes-dashboard The dashboard service is now exposed on external port 30009. Access it in a browser at https://<master-ip>:30009/.
To log in, create a service account with cluster‑admin privileges and retrieve its token:
# Create service account
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard
# Bind cluster‑admin role
kubectl create clusterrolebinding dashboard-admin-rb --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:dashboard-admin
# Get the secret name
kubectl get secrets -n kubernetes-dashboard | grep dashboard-admin
# Describe the secret to obtain the token
kubectl describe secrets dashboard-admin-token-<i>xxxxx</i> -n kubernetes-dashboardUse the extracted token on the dashboard login page.
Additional useful commands include listing all pods across namespaces and checking the dashboard service details:
kubectl get pod --all-namespaces
kubectl -n kube-system get service kubernetes-dashboardThese steps provide a complete, hands‑on setup for the Kubernetes dashboard, enabling visual management of cluster workloads.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
