How to use the Kubernetes dashboard with DigitalOcean

Posted by Harald Nezbeda on Sun 16 June 2019

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:

Download the Kubernetes Configuration

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
Add ServiceAccount and a cluster role binding. Create the file serviceaccount.yaml containing:
apiVersion: v1
kind: ServiceAccount
  name: k8s-test # replace with your preferred username
  namespace: kube-system
kind: ClusterRoleBinding
  name: k8s-test # replace with your preferred username
  kind: ClusterRole
  name: cluster-admin
- 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 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

Get the k8s token


Start the dashboard
kubectl --kubeconfig="k8s-test-1-kubeconfig.yaml" proxy
Open the WEB UI
Login using Token

Kubernetes login