How to Install and Access the Kubernetes Dashboard in a k3s Cluster

Deploying the Dashboard UI

Note:

Kubernetes Dashboard supports only Helm-based installation currently as it is faster and gives us better control over all dependencies required by Dashboard to run.

The Dashboard UI is not deployed by default. To deploy it, run the following command:

# Add kubernetes-dashboard repository
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
# Deploy a Helm Release named "kubernetes-dashboard" using the kubernetes-dashboard chart
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard

Accessing the Dashboard UI

Run the below command to retrieve the IP address of the service/kubernetes-dashboard-kong-proxy.

kubectl get all -n kubernetes-dashboard

To access this ClusterIP, I am using OpenVPN inside the cluster. To install OpenVPN, click here 😀. Alternatively, you can edit the service and change its type to LoadBalancer.

Now, open the IP address in your browser.

URL Example:
https://{“Your Cluster IP” or “LoadBalancer Public IP”}/#/login

Now we have to generate Bearer Token to sign into the dashboard. to do run the bellow commands:

Create a Service Account

You need a service account with the appropriate permissions to access the dashboard.

kubectl create serviceaccount dashboard-sa -n kubernetes-dashboard

Bind a Role to the Service Account

Bind the service account to a ClusterRole or Role that grants access to the dashboard. For full cluster access:

kubectl create clusterrolebinding dashboard-sa-binding \
  --clusterrole=cluster-admin \
  --serviceaccount=kubernetes-dashboard:dashboard-sa
Note:

Using cluster-admin grants full access to the cluster, which is not recommended for production. Use a more restrictive role for better security.

Generate the Bearer Token

Use the following command to generate a token for the service account:

kubectl -n kubernetes-dashboard create token dashboard-sa

This will output the token, which you will use to log in to the Kubernetes Dashboard.

Paste the token and click sign in

logged in ✌️

Note:

I am using OpenVPN inside the cluster; that’s why I am accessing the UI using ClusterIP.

Leave a Reply

Your email address will not be published. Required fields are marked *