Accessing the Kubernetes dashboard from a Kubespray-deployed cluster

February 10, 2019   

Kubespray installs the Kubernetes Dashboard, which is easily accessible with a few quick steps.

Sample User

Create a new Service Account:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
$ kubectl apply -f 1-service-account.yml

Apply the Cluster Role Binding:

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: kube-system
$ kubectl apply -f 2-cluster-role-binding.yml

Generate login token:

$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Dashboard

Start a kubectl proxy:

$ kubectl proxy

Open your browser, and hit the login page:

http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

Select “Token” from the login options, and paste in the value of “token:” as returned from the previous secret command.