Kubernetes dashboard is a web-based user interface which provides information on the state of the Kubernetes cluster resources and any errors that may occur. The dashboard can be used to deploy containerized applications to the cluster, troubleshoot deployed applications, as well as the general management of the cluster resources.
The deployment of Deployments, StatefulSets, DaemonSets, Jobs, Services and Ingress can be done from the dashboard or from the terminal with kubectl. if you want to scale a Deployment, initiate a rolling update, restart a pod, create a persistent volume and persistent volume claim, you can do all from the Kubernetes dashboard.
Also checkout the article on Authenticate Kubernetes Dashboard Users With Active Directory
Step 1: Configure kubectl
We’ll use the kubectl kubernetes management tool to deploy dashboard to the Kubernetes cluster. You can configure kubectl using our guide below.
The guide in the link demonstrates how you can configure and access multiple clusters with same kubectl configuration file.
Step 2: Deploy Kubernetes Dashboard
The default Dashboard deployment contains a minimal set of RBAC privileges needed to run. You can deploy Kubernetes dashboard with the command below.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml
You can as well download and apply the file locally:
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml
kubectl apply -f recommended.yaml
Set Service to use NodePort
This will use the default values for the deployment. The services are available on ClusterIPs only as can be seen from the output below:
$ kubectl get svc -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.104.220.36 8000/TCP 23s
kubernetes-dashboard ClusterIP 10.108.11.22 443/TCP 25s
Patch the service to have it listen on NodePort:
kubectl --namespace kubernetes-dashboard patch svc kubernetes-dashboard -p '"spec": "type": "NodePort"'
Confirm the new setting:
$ kubectl get svc -n kubernetes-dashboard kubernetes-dashboard -o yaml
...
spec:
clusterIP: 10.108.11.22
clusterIPs:
- 10.108.11.22
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- nodePort: 30506
port: 443
protocol: TCP
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort
status:
loadBalancer:
- NodePort exposes the Service on each Node’s IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created.
$ vim nodeport_dashboard_patch.yaml
spec:
ports:
- nodePort: 32000
port: 443
protocol: TCP
targetPort: 8443
EOF
Apply the patch
kubectl -n kubernetes-dashboard patch svc kubernetes-dashboard --patch "$(cat nodeport_dashboard_patch.yaml)"
Check deployment status:
$ kubectl get deployments -n kubernetes-dashboard
NAME READY UP-TO-DATE AVAILABLE AGE
dashboard-metrics-scraper 1/1 1 1 86s
kubernetes-dashboard 1/1 1 1 86s
Two pods should be created – One for dashboard and another for metrics.
$ kubectl get pods -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-7b64584c5c-xvtqp 1/1 Running 0 2m4s
kubernetes-dashboard-566f567dc7-w59rn 1/1 Running 0 2m4s
Since I changed service type to NodePort, let’s confirm if the service was actually created.
$ kubectl get service -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.103.159.77 8000/TCP 8m40s
kubernetes-dashboard NodePort 10.101.194.22 443:32000/TCP 8m40s
Step 3: Accessing Kubernetes Dashboard
My Service deployment was assigned a port 32000/TCP.
# Example
https://192.168.200.14:32000
Let’s confirm if access to the dashboard is working.
You need a token to access the dashboard, check our guides:
- How To Create Admin User to Access Kubernetes Dashboard
- Create Kubernetes Service / User Account restricted to one Namespace
You should see a web dashboard which looks similar to below.
Nginx Ingress:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: k8s-dashboard
namespace: kubernetes-dashboard
annotations:
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
tls:
- hosts:
- k8sdash.mydomain.com
secretName: tls-secret
rules:
- host: k8sdash.mydomain.com
http:
paths:
- path: /
backend:
serviceName: kubernetes-dashboard
servicePort: 443