Cloud Native 4 min read

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.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Deploying and Accessing the Kubernetes Dashboard Using YAML and kubectl

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-dashboard

Apply 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-dashboard

Use 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-dashboard

These steps provide a complete, hands‑on setup for the Kubernetes dashboard, enabling visual management of cluster workloads.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeDevOpsDashboardYAMLkubectl
Practical DevOps Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.