Kubernetes Cluster Role Binding for Kubernetes Dashboard UI (User Interface)
By default, the dashboard has restricted access; you’ll have to create a service account and connect a cluster role to give it the necessary features.
kubectl create serviceaccount dashboard-admin-sa
Next, create a cluster role binding that grants the service account the cluster-admin role:
kubectl create cluster role binding dashboard-admin-sa \
--clusterrole=cluster-admin \
--serviceaccount=default:dashboard-admin-sa
Keeping the token used for dashboard authentication secure will prevent the dashboard from doing any action on your cluster.
Execute the file on the master node using the below command:
kubectl apply -f sa-dashboard.yaml
Get the Token for the Service Account
To log in to the dashboard, you will need the token for the service account you created in Step 2. You can retrieve the token using the following command:
- Use the below command to obtain the service account; for reference, check the image below.
kubectl get sa -n kube-system
- Use the below command to obtain the secret; for reference, check the image below.
kubectl describe sa dashboard-admin -n kube-system
- Get the token by using the below command for reference, check the image below.
kubectl describe secret dashboard-admin-token-v5g7h -n kube-system
- Start Kubernetes proxy in order to access the Kubernetes dashboard from your local machine.
kubectl proxy
This command will create the proxy servers and you can access the dashboard.
Kubernetes – Dashboard Setup
Kubernetes – Dashboard Setup is a web-based user interface that offers a summary of your Kubernetes cluster. You may manage your resources using a graphical interface and view information about your pods, deployments, services, and more with the dashboard. How do you maintain track of all the containers you deploy using Kubernetes when there are hundreds of them? That won’t work with a command-line interface. Everything must be represented visually. Welcome to the Kubernetes dashboard. The official web-based UI for Kubernetes, known as Kubernetes Dashboard, consists of a collection of services that make cluster management easier. You will discover how to set up the Kubernetes Dashboard on an Ubuntu computer step-by-step in this guide.