In this episode, we'll discuss Kubernetes Dashboard for managing clusters through a web UI. We'll learn how to install Dashboard v2.7.0, create admin users, access the dashboard, and best practices for secure dashboard deployment.

Note
If you want to read the previous episode, you can click the Episode 27 thumbnail below
In the previous episode, we learned about StatefulSet for managing stateful applications with stable identities and persistent storage. In episode 28, we'll discuss Kubernetes Dashboard, a web-based UI for managing and monitoring your Kubernetes cluster.
Note: Here I'll be using a Kubernetes Cluster installed through K3s.
While kubectl is powerful for command-line management, Kubernetes Dashboard provides a visual interface for viewing cluster resources, deploying applications, troubleshooting issues, and monitoring workloads - making cluster management more accessible.
Kubernetes Dashboard is a general-purpose, web-based UI for Kubernetes clusters. It allows users to manage applications running in the cluster, troubleshoot applications, and manage cluster resources.
Think of Dashboard like a control panel for your cluster - instead of typing commands, you can click through resources, view logs, edit configurations, and monitor health through an intuitive interface.
Key features of Kubernetes Dashboard:
Dashboard solves several challenges:
Without Dashboard, you rely entirely on kubectl, which can be challenging for beginners or teams preferring visual interfaces.
Let's install Dashboard v2.7.0 step by step.
Apply the official Dashboard manifest:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yamlThis creates:
kubernetes-dashboardkubernetes-dashboardkubernetes-dashboardCheck Dashboard pods:
kubectl get pods -n kubernetes-dashboardOutput:
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-5cb4f4bb9c-xxxxx 1/1 Running 0 1m
kubernetes-dashboard-79cbcf9fb6-xxxxx 1/1 Running 0 1mCheck Dashboard service:
kubectl get svc -n kubernetes-dashboardOutput:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.43.xxx.xxx <none> 8000/TCP 1m
kubernetes-dashboard ClusterIP 10.43.xxx.xxx <none> 443/TCP 1mDashboard requires authentication. Create a ServiceAccount with admin privileges.
Create dashboard-admin.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-dashboardApply the configuration:
kubectl apply -f dashboard-admin.ymlWarning
Security Warning: This creates a user with cluster-admin privileges. For production, use more restrictive RBAC roles.
Create a token for the admin user:
kubectl -n kubernetes-dashboard create token admin-userOutput (example):
eyJhbGciOiJSUzI1NiIsImtpZCI6IjRxN3Z...very-long-token...xyz123Copy this token - you'll need it to log in to Dashboard.
Note
Tokens created with create token are short-lived (default 1 hour). For long-lived tokens, create a Secret manually.
There are several ways to access Dashboard:
Forward Dashboard service to localhost:
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard 8443:443Access Dashboard at: https://localhost:8443
Kubernetes Dashboard Login
Kubernetes Dashboard WorkloadEdit the Dashboard service:
kubectl edit svc kubernetes-dashboard -n kubernetes-dashboardChange type: ClusterIP to type: NodePort:
spec:
type: NodePort # Changed from ClusterIP
ports:
- port: 443
targetPort: 8443
nodePort: 30443 # Optional: specify portGet the NodePort:
kubectl get svc -n kubernetes-dashboardAccess Dashboard at: https://<node-ip>:<node-port>
Create an Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-dashboard
namespace: kubernetes-dashboard
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
ingressClassName: nginx
tls:
- hosts:
- dashboard.example.com
secretName: dashboard-tls
rules:
- host: dashboard.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443You're now logged in to Kubernetes Dashboard!
Cluster:
Workloads:
Service:
Config and Storage:
Custom Resources:
Navigate to any resource type:
Example form deployment:
App name: nginx-app
Container image: nginx:1.25
Number of pods: 3
Service: External (NodePort)
Port: 80
Target port: 80For persistent access, create a Secret-based token.
apiVersion: v1
kind: Secret
metadata:
name: admin-user-token
namespace: kubernetes-dashboard
annotations:
kubernetes.io/service-account.name: admin-user
type: kubernetes.io/service-account-tokenApply:
kubectl apply -f admin-user-secret.ymlkubectl get secret admin-user-token -n kubernetes-dashboard -o jsonpath="{.data.token}" | base64 --decodeThis token doesn't expire and can be used for long-term access.
For users who should only view resources:
apiVersion: v1
kind: ServiceAccount
metadata:
name: readonly-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: readonly-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- kind: ServiceAccount
name: readonly-user
namespace: kubernetes-dashboardApply:
kubectl apply -f dashboard-readonly.ymlGenerate token:
kubectl -n kubernetes-dashboard create token readonly-userFor users limited to specific namespace:
apiVersion: v1
kind: ServiceAccount
metadata:
name: dev-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: dev-user
namespace: development
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: edit
subjects:
- kind: ServiceAccount
name: dev-user
namespace: kubernetes-dashboardThis user can only access the development namespace.
Check pod status:
kubectl get pods -n kubernetes-dashboardView pod logs:
kubectl logs -n kubernetes-dashboard deployment/kubernetes-dashboardDescribe pod:
kubectl describe pod -n kubernetes-dashboard <pod-name>Check service:
kubectl get svc -n kubernetes-dashboard
kubectl describe svc kubernetes-dashboard -n kubernetes-dashboardVerify port-forward is running:
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard 8443:443Verify ServiceAccount exists:
kubectl get sa admin-user -n kubernetes-dashboardVerify ClusterRoleBinding:
kubectl get clusterrolebinding admin-userGenerate new token:
kubectl -n kubernetes-dashboard create token admin-userDashboard uses self-signed certificates by default. For production:
apiVersion: v1
kind: Secret
metadata:
name: kubernetes-dashboard-certs
namespace: kubernetes-dashboard
type: kubernetes.io/tls
data:
tls.crt: <base64-encoded-cert>
tls.key: <base64-encoded-key>Problem: Giving everyone full cluster access.
Solution: Create role-specific users:
# Read-only user
roleRef:
kind: ClusterRole
name: view
# Edit user (no delete)
roleRef:
kind: ClusterRole
name: editProblem: Dashboard accessible from internet without proper security.
Solution: Use one of these approaches:
Problem: Dashboard pods can consume unlimited resources.
Solution: Edit deployment to add limits:
kubectl edit deployment kubernetes-dashboard -n kubernetes-dashboardAdd:
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"Problem: Tokens expire after 1 hour.
Solution: Create Secret-based tokens for automation:
apiVersion: v1
kind: Secret
metadata:
name: admin-user-token
annotations:
kubernetes.io/service-account.name: admin-user
type: kubernetes.io/service-account-tokenProblem: No audit trail of Dashboard usage.
Solution: Enable audit logging in Kubernetes API server and monitor Dashboard access patterns.
Use strong authentication:
# Minimum privileges principle
roleRef:
kind: ClusterRole
name: view # Not cluster-adminSecure Dashboard with proper certificates:
spec:
tls:
- hosts:
- dashboard.example.com
secretName: dashboard-tls-certRestrict Dashboard network access:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: dashboard-access
namespace: kubernetes-dashboard
spec:
podSelector:
matchLabels:
k8s-app: kubernetes-dashboard
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: ingress-nginx
ports:
- protocol: TCP
port: 8443Prevent resource exhaustion:
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"Create role-specific users:
# Admin user - full access
# Developer user - namespace-specific
# Viewer user - read-onlyRotate tokens periodically:
# Delete old token
kubectl delete secret admin-user-token -n kubernetes-dashboard
# Create new token
kubectl apply -f admin-user-secret.ymlTrack who accesses Dashboard and what they do:
kubectl logs -n kubernetes-dashboard deployment/kubernetes-dashboardRegularly update to latest version:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yamlWhile Dashboard is official, consider alternatives:
Lens:
K9s:
Octant:
Rancher:
kubectl get all -n kubernetes-dashboardkubectl get deployment kubernetes-dashboard -n kubernetes-dashboard -o jsonpath="{.spec.template.spec.containers[0].image}"kubectl logs -n kubernetes-dashboard deployment/kubernetes-dashboard -fkubectl describe svc kubernetes-dashboard -n kubernetes-dashboardkubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yamlkubectl delete -f dashboard-admin.ymlkubectl delete namespace kubernetes-dashboardIn episode 28, we've explored Kubernetes Dashboard in depth. We've learned how to install Dashboard v2.7.0, create admin users, access the dashboard securely, and manage cluster resources through a web interface.
Key takeaways:
kubectl apply commandKubernetes Dashboard makes cluster management accessible through an intuitive web interface. By understanding Dashboard installation and security best practices, you can provide your team with visual cluster management while maintaining proper access controls.
Are you getting a clearer understanding of Kubernetes Dashboard? Keep your learning momentum going and look forward to the next episode!
Note
If you want to continue to the next episode, you can click the Episode 29 thumbnail below