【问题标题】:kubernetes remote access dashboardKubernetes 远程访问仪表板
【发布时间】:2019-12-24 07:29:53
【问题描述】:

在开始之前我只有一个关于kubernetes的问题,通常linux服务器没有图形界面,那么管理员如何访问k8S仪表板?

除了 ssh 隧道还有其他解决方案吗?

我尝试了 ssh 隧道,但无法正常工作

我已执行的主命令:

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

在远程机器上完成隧道 SSH:

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.

来自远程机器的浏览器消息:

  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

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

【问题讨论】:

  • 您能否提供您尝试访问仪表板的完整 URL?

标签: kubernetes


【解决方案1】:

我做了一个 UI 工具来帮助您将任何服务转发到您的本地机器。

您可以查看如何转发仪表板的示例:

这里是关于如何开始的存储库链接:linker-tool

如果您有任何问题,请打开问题或与我联系,我很乐意为您提供帮助。

【讨论】:

    【解决方案2】:

    很久以前我用is-accessing-kubernetes-dashboard-remotely-possible文章解决了同样的问题。这种方法也适用于 ssh 隧道

    1) 部署仪表板(您可以从original source 获取)

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

    2)kubectl proxy&

    3) 创建 serviceaccount,授予它 cluster-admin 角色

    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)
    

    4) 从集群外部的远程主机创建 ssh 隧道,您可以在其中访问仪表板:

    ssh -L 9999:127.0.0.1:8001 -N -f -l rab <k8s master host name or ip>
    

    “-L”本地端口转发

    “9999”是本地主机端口。它可以是任何可用的端口。也可以是8001 “127.0.0.1:8001”是代理在k8s master主机上运行的地方

    在主控主机上创建隧道可能需要密码 此命令将端口 9999 上的任何本地请求转发到 master 主机上的“127.0.0.1:8001”

    5)使用以下api打开浏览器:

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

    然后选择“令牌”并通过令牌以登录仪表板。

    希望对你有帮助

    【讨论】:

    • Ssh 隧道似乎不起作用,ssh 隧道适用于 mailhog 应用程序测试,但使用仪表板它不起作用。我已经在我的服务器上安装了桌面,我可以连接到仪表板。
    猜你喜欢
    • 2019-12-22
    • 1970-01-01
    • 2018-04-20
    • 2020-06-02
    • 2020-03-19
    • 1970-01-01
    • 1970-01-01
    • 2016-12-08
    相关资源
    最近更新 更多