For this tutorial I assume you already have a DigitalOcean account and have already added a Kubernetes Cluster. If not, register using this link and get a $50 bonus that can be used for 30 days.
The dashboard is a Web UI that helps interacting with Kubernetes (k8s) and control all configurations. On other services, such as Microsoft Azure, you are provided with this by default, for DigitalOcean some extra steps are required.
Download the Kubernetes configuration
Download the Kubernetes configuration from the DigitalOcean dashboard:
Create a local directory for the k8s configurations. Usually this is called ".kube":
mkdir ~/.kube && cd ~/.kube
Move the k8s configuration to the configurations directory:
mv ~/downloads/k8s-test-1-kubeconfig.yaml ~/.kube
Test the configuration. Read the list of nodes:
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" get nodes
Deploy the Kubernetes dashboard
Create the deployment
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
Add ServiceAccount and a cluster role binding. Create the file serviceaccount.yaml
containing:
apiVersion: v1
kind: ServiceAccount
metadata:
name: k8s-test # replace with your preferred username
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: k8s-test # replace with your preferred username
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: k8s-test # replace with your preferred username
namespace: kube-system
Replace k8s-test
with your preferred username. This is required to find the token in the steps bellow.
Apply the ServiceAccount configuration
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" apply -f serviceaccount.yaml
Get the service that provides the token
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" get secret -n kube-system
You will find in the list something containing the name used in the Service Account, the string token
, a hash value and it will be of the type kubernetes.io/service-account-token
. In my case it was k8s-test-token-nwjw6
(use this in the next step).
Get the token
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" describe secret k8s-test-token-nwjw6 -n kube-system
Login
Start the dashboard
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" proxy
Open the WEB UI
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/