<p>Before to start I have just one question about kubernetes, usually linux server have  not graphic interface, so how the admin can access to k8S dashboard ?</p>

<p>Is there any other solution expect ssh tunnel ?</p>

<p>I have tried ssh tunnel but not working</p>

<p>Master command I have executed:</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta1/aio/deploy/recommended.yaml
namespace/kubernetes-dashboard unchanged
serviceaccount/kubernetes-dashboard unchanged
service/kubernetes-dashboard unchanged
secret/kubernetes-dashboard-certs unchanged
secret/kubernetes-dashboard-csrf unchanged
secret/kubernetes-dashboard-key-holder unchanged
configmap/kubernetes-dashboard-settings unchanged
role.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
deployment.apps/kubernetes-dashboard configured
service/dashboard-metrics-scraper configured
deployment.apps/kubernetes-metrics-scraper created
[rbo@K8SMaster ~]$ kubectl proxy
Starting to serve on 127.0.0.1:8001
</code></pre>

<p>Tunnel SSH done on remote machine:</p>

<pre><code>Authenticated to k8smaster ([192.168.1.15]:22).
debug1: Local connections to LOCALHOST:8080 forwarded to remote address localhost:8001
debug1: Local forwarding listening on ::1 port 8080.
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 8080.
debug2: fd 6 setting O_NONBLOCK
debug1: channel 1: new [port listener]
debug2: fd 3 setting TCP_NODELAY
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
</code></pre>

<p>Browser message from remote machine:</p>

<pre><code>  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "services \"kubernetes-dashboard\" not found",
  "reason": "NotFound",
  "details": {
    "name": "kubernetes-dashboard",
    "kind": "services"
  },
  "code": 404
}
</code></pre>

rab
<p>A long time ago I used <a href="https://www.edureka.co/community/31282/is-accessing-kubernetes-dashboard-remotely-possible" rel="nofollow noreferrer">is-accessing-kubernetes-dashboard-remotely-possible</a> article to resolve the same. This approach also with ssh tunnel</p>

<p>1) Deploy dashboard (you may take it from <a href="https://github.com/kubernetes/dashboard" rel="nofollow noreferrer">original source</a>)</p>

<pre><code>$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yam
</code></pre>

<p>2) <code>kubectl proxy&amp;</code></p>

<p>3) Create serviceaccount, grant it cluster-admin role</p>

<pre><code>kubectl create serviceaccount rab
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=default:rab
kubectl get secret
kubectl describe secret rab-token-***** (and retrieve token from output. You will need it to access dashboard in the future steps)
</code></pre>

<p>4)create ssh tunnel from a remote host outside of the cluster where you would access dashboard:</p>

<pre><code>ssh -L 9999:127.0.0.1:8001 -N -f -l rab &lt;k8s master host name or ip&gt;
</code></pre>

<p>"-L" local port forwarding</p>

<p>"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</p>

<p>Password may be required for the  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</p>

<p>5)open a browser with the following api:</p>

<pre><code>http://localhost:9999/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
</code></pre>

<p>Then select "token" and past the token to log in the dashboard.</p>

<p>Hope it helps you</p>
