# Accessing Kubernetes Dashboard

To install kubernetes dashboard on master node make sure to install it before worker nodes join k8s cluster.

## Obtain login token for service account (on master)

```shell
SA_NAME="<service-account-name>"
# eg SA_NAME="techiterian-cluster-admin"
```

to print token

```shell
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep ${SA_NAME} | awk '{print $1}')
```

Service account along with a token will be printed

```shell
techiterian@prd-master1:~/Documents/k8s-rapidoreach-prod$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep ${SA_NAME} | awk '{print $1}')
Name:         techiterian-cluster-admin-token-cvmgg
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: techiterian-cluster-admin
              kubernetes.io/service-account.uid: e5538ac5-41c1-44aa-9f4e-b06888cc86f0

Type:  kubernetes.io/service-account-token

Data
====
namespace:  11 bytes
token:      <token here>
ca.crt:     1066 bytes
```

## Start proxy to access kubernetes dashboard (on master)

```shell
kubectl proxy
```

## Open ssh tunnel (on local machine)

Kubernetes dashboard will currently be accessible only from master node where kubectl proxy is executed. To access it from remote machine use ssh tunnel

```shell
ssh -L 8001:localhost:8001 techiterian@prd-master1.rapidoreach.com
```

Above command will open ssh tunnel which will forward all traffic from localhost port 8001 to kubernetes proxy port 8001

## Access Kubernetes dashboard using url

[http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/](http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/)

> Kubernetes dashboard is not accessible from local machine