Is accessing kubernetes dashboard remotely possible?

+1 vote
Is accessing kubernetes dashboard remotely possible?
Nov 23, 2018 in Kubernetes by Ali
• 10,400 points
3,633 views

4 answers to this question.

+1 vote

To access to Kubernetes Dashboard via proxy from remote machine, you will need to grant ClusterRole to allow access to dashboard.

Create new file and insert following details.

vi dashboard-access.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: kube-dashboard
  labels:
    k8s-app: kube-dashboard
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: kube-dashboard
  namespace: kube-system

Now apply changes to Kubernetes Cluster to grant access to dashboard.

kubectl create -f dashboard-access.yaml
answered Nov 23, 2018 by Hannah
• 14,070 points
+1 vote
As far as I know, I don't think it's possible to access the dashboard remotely. You can only access your dashboard from the master node.
answered Apr 26 by Vaidya
+1 vote

Kubernetes API server is exposed and accessible from outside you can directly access dashboard at: 

https://<master-ip>:<apiserver-port>/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
answered Apr 26 by Rick
0 votes

It seems only the api request from localhost to the dashboard service can be accepted in proxy mode. Then the quest becomes how to make a request from a remote host look like from localhost of where the proxy is running (k8s master node, in my case).

Here are the steps:

1,  deploy dashboard serive on master node:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml

2, start proxy: 
kubectl proxy&

3, create your own secret and obtain the token:
kubectl create serviceaccount <account name>
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=default:<account name>
kubectl get secret
kubectl describe secret <secret name>

4, create ssh tunnel from a remote host outside of the cluster where you would access dashboard:
ssh -L 9999:127.0.0.1:8001 -N -f -l <user name> <k8s master host name or ip>
"-L" local port forwarding
"9999" is a local host port. it can be any available port. It can also be 8001
"127.0.0.1:8001" is where the proxy runs on k8s master host
Password may be required for the <user name> on the master host to create a tunnel
This command forwards any local request on port 9999 to"127.0.0.1:8001" on the master host

5, open a browser with the following api:
http://localhost:9999/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Then select "token" and past the token to log in the dashboard.

This approach does not require any addtional configuration in k8s cluster. It is recommended by Oracle: https://docs.oracle.com/cd/E52668_01/E88884/html/kube_admin_dashboard.html
Good luck.
answered May 2 by Ling
Hey @Ling, Thanks for such a nice explanation. I shall try it out. But could you please explain the third step? I do not understand why do we need to create a secret token?
Thanks a lot. This comment helped me solve the issue.

Related Questions In Kubernetes

0 votes
0 answers

Kubernetes dashboard Url is not accessing in my browser?

im facing the issue from yesterday.  i ...READ MORE

Jun 19 in Kubernetes by anonymous

closed Jun 20 by Kalgi 78 views
0 votes
2 answers

Accessing Kubernetes Web UI (Dashboard)

To access Kubernetes dashboard, you need to ...READ MORE

answered Apr 15 in Kubernetes by Ray
289 views
+1 vote
1 answer

Is autoscaling possible in kubernetes ingress nginx

In principle, the NGINX ingress controller is ...READ MORE

answered Oct 24, 2018 in Kubernetes by Kalgi
• 40,440 points
105 views
+3 votes
1 answer
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
2,096 views
0 votes
1 answer
0 votes
1 answer