<p>I am trying to access the kubernetes Dashboard using the Token method outside the network.</p>

<p>I ran these 2 commands to get the token</p>

<pre><code>kubectl -n kube-system get secret

kubectl -n kube-system describe secret replicaset-controller-token-2p4fk
</code></pre>

<p>Copy paste output token into K8 Login page. </p>

<p>I'm getting this error browser console when I click on Sign in button (Page is not loading).</p>

<p><a href="https://i.stack.imgur.com/nyd13.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/nyd13.jpg" alt="enter image description here"></a></p>

<p>I'm running k8 on the internal server using the command:</p>

<pre><code>kubectl proxy --address 0.0.0.0 --accept-hosts '.*'
</code></pre>

<p>And trying to access the k8 UI console from <strong>outside network</strong>.</p>

<pre><code>Failed to load resource: the server responded with a status of 401 (Unauthorized)
vendor.bd425c26.js:6 Error during global settings reload:  Object
:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/api/v1/rbac/status:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
vendor.bd425c26.js:6 Possibly unhandled rejection: {"data":"MSG_LOGIN_UNAUTHORIZED_ERROR\n","status":401,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"api/v1/rbac/status","headers":{"Accept":"application/json, text/plain, */*"}},"statusText":"Unauthorized","xhrStatus":"complete","resource":{}}
</code></pre>

<p>I even tried these steps but no luck the page is not loading on clicking Sign in button.</p>

<pre><code>$ kubectl -n kube-system get secret
# All secrets with type 'kubernetes.io/service-account-token' will allow to log in.
# Note that they have different privileges.
NAME                                     TYPE                                  DATA      AGE
deployment-controller-token-frsqj        kubernetes.io/service-account-token   3         22h

$ kubectl -n kube-system describe secret deployment-controller-token-frsqj
Name:         deployment-controller-token-frsqj
Namespace:    kube-system
Labels:       &lt;none&gt;
Annotations:  kubernetes.io/service-account.name=deployment-controller
              kubernetes.io/service-account.uid=64735958-ae9f-11e7-90d5-02420ac00002

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1025 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZXBsb3ltZW50LWN
</code></pre>

<p><strong>Here is my Kube/config file</strong></p>

<pre><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRV..
    server: https://192.168.15.97:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: LS0tLS1CRUdJTiBD..
    client-key-data: LS0tLS1CRUdJTiBSU0EgUFJ..
</code></pre>

<p>And why is that I'm not seeing <strong>Skip</strong>  auth button next to Sign button?</p>

<p><strong>I tried these steps as well:</strong></p>

<p>Run the following commands:</p>

<ol>
<li><p>This command will create a service account for the dashboard in the default namespace</p>

<p><code>$kubectl create serviceaccount dashboard -n default</code></p></li>
<li><p>This command will add the cluster binding rules to your dashboard account</p>

<p>kubectl create clusterrolebinding dashboard-admin -n default \
  --clusterrole=cluster-admin \
  --serviceaccount=default:dashboard</p></li>
<li><p>This command will give you the token required for your dashboard login</p>

<p><code>$kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode</code>
Can some help me here what am i missing out.</p></li>
</ol>

<p><strong>Some Findings:</strong> <a href="https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard---1.7.X-and-above" rel="noreferrer">Link</a>
kubectl proxy command only allows HTTP connection. For domains other than localhost and 127.0.0.1 it will not be possible to sign in. Nothing will happen after clicking Sign in button on login page.</p>

<pre><code>kubectl proxy
</code></pre>

<p>Doesn't support https calls. </p>

<p><strong>Is there a way to run <em>kubectl proxy</em> command along with Kubernetes Server IP Address from an outside/Local windows network ?</strong> </p>

<p><strong>Note:</strong>
The local system is a Windows 10 &amp; K8 is a Linux server.
Docker Version: 18.09 &amp; k8 Version: v1.13.1</p>

<p>Thanks,</p>

MAX
<p>I have this issue when I try to get access to the dashboard via <code>kubectl proxy</code> using plain http and public ip. </p>

<p>Error details: <code>kubectl proxy</code> produces errors <code>http: proxy error: context canceled</code> in console, in browser after you click "sign in" one of the requests which ends with <code>/plugin/config</code> returns json with <code>MSG_LOGIN_UNAUTHORIZED_ERROR</code> but the browser doesn't display any error.</p>

<p>The solution (<a href="https://github.com/kubernetes/dashboard/blob/master/docs/user/accessing-dashboard/README.md" rel="noreferrer">source</a>)</p>

<pre><code>kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 8443:443 --address 0.0.0.0
</code></pre>

<p>Of course you can use your interface ip instead of 0.0.0.0 if you want to bind it to one interface only. Then go to <code>https://your.external.ip:8443/</code>, it'll redirect you to <code>https://your.external.ip:8443/#/login</code> and you'll be asked for the token. Next, as described <a href="https://stackoverflow.com/a/47761914/1013183">here</a>:</p>

<pre><code>kubectl -n kube-system describe secret $(kubectl -n kube-system get secret \
| awk '/^deployment-controller-token-/{print $1}') | awk '$1=="token:"{print $2}'
</code></pre>
