How I Enabled K8s Dashboard v3 on Docker Desktop
K8s v3.0.0-alpha0 Dashboard
K8s Dashboard Installation
On K8s provided by Docker Desktop by default, you will have the following namespaces
Following the steps available in the below official Github Repository: https://github.com/kubernetes/dashboard/releases
Using Helm to install the dashboard
Check the below link for any additional configurations you need more than the default ones, https://artifacthub.io/packages/helm/k8s-dashboard/kubernetes-dashboard
# 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# Uninstalling the Chart
helm delete kubernetes-dashboard --namespace kubernetes-dashboard# Remove kubernetes-dashboard repository
helm repo remove kubernetes-dashboard
You will get the following weird error, you can safely ignore it.
Accessing K8s Dashboard
The following link contains the description of each step I wanted to keep this blog as straightforward as possible https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
Create a Sample Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
Creating a ClusterRoleBinding
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-dashboard
Getting a long-lived Bearer Token for ServiceAccount
apiVersion: v1
kind: Secret
metadata:
name: admin-user
namespace: kubernetes-dashboard
annotations:
kubernetes.io/service-account.name: "admin-user"
type: kubernetes.io/service-account-token
Get the Bearer Toker value:
kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath="{".data.token"}"
After that decode the outputted string with base64, I used this website https://www.base64decode.org/, then you can use it to access the dashboard in the following step.
Port Forwarding to K8s Dashboard Nginx Controller
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-nginx-controller 8443:443
You can then access the dashboard using the following link https://localhost:8443, and use the token you already created.