简体   繁体   English

如何使用令牌远程访问 kubernetes 仪表板

[英]How can I remotely access kubernetes dashboard with token

There are many guides, answers, etc... that specifically show how to enable the kubernetes dashboard, and several that attempt to explain how to remotely access them, but many have an issue with regard to accepting the token once you get to the login screen.有许多指南、答案等……专门展示了如何启用 kubernetes 仪表板,还有一些试图解释如何远程访问它们,但许多在登录后接受令牌存在问题屏幕。

The problem as I understand it is that the service does not (rightfully) accept remote tokens over http.据我了解,问题是该服务不(理所当然地)通过 http 接受远程令牌。 Even though I can get to the login screen I can't get into the dashboard due to the inability to use the token.尽管我可以进入登录屏幕,但由于无法使用令牌而无法进入仪表板。 How can I get around this limitation?我怎样才能绕过这个限制?

Taken from https://www.edureka.co/community/31282/is-accessing-kubernetes-dashboard-remotely-possible :摘自https://www.edureka.co/community/31282/is-accessing-kubernetes-dashboard-remotely-possible

you need to make the request from the remote host look like it's coming from a localhost (where the dashboard is running):您需要使来自远程主机的请求看起来像是来自本地主机(仪表板运行的地方):

From the system running kubernetes / dashboard:从运行 kubernetes/dashboard 的系统:

Deploy the dashboard UI:部署仪表板 UI:

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

Start the proxy:启动代理:

kubectl proxy& kubectl代理&

Create a secret:创建一个秘密:

kubectl create serviceaccount [account name] kubectl create serviceaccount [账户名]

kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=default:[account name] kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=default:[账户名]

kubectl get secret kubectl 获取秘密

kubectl describe secret [account name] kubectl describe secret [账户名]

From the system you wish to access the dashboard:从您希望访问仪表板的系统:

Create an ssh tunnel to the remote system (the system running the dashboard):创建到远程系统(运行仪表板的系统)的 ssh 隧道:

ssh -L 9999:127.0.0.1:8001 -N -f -l [remote system username] [ip address of remote system] -P [port you are running ssh on] ssh -L 9999:127.0.0.1:8001 -N -f -l [远程系统用户名] [远程系统的 IP 地址] -P [正在运行 ssh 的端口]

You will likely need to enter a password unless you are using keys.除非您使用密钥,否则您可能需要输入密码。 Once you've done all this, from the system you established the ssh connection access http://localhost:9999/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/完成所有这些后,从您建立的系统中建立 ssh 连接访问http://localhost:9999/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

You can change the port 9999 to anything you'd like.您可以将端口 9999 更改为任何您想要的。

Once you open the browser url, copy the token from the "describe secret" step and paste it in.打开浏览器 url 后,从“描述秘密”步骤复制令牌并将其粘贴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM